Project-MONAI / MONAI

AI Toolkit for Healthcare Imaging
https://monai.io/
Apache License 2.0
5.93k stars 1.09k forks source link

ImportError: cannot import name 'get_act_layer' #3275

Closed LaiaHumbertVidan closed 3 years ago

LaiaHumbertVidan commented 3 years ago

Describe the bug When trying to import get_act_layer using 'from monai.networks.layers import get_act_layer' I get an error which I am unable to solve or find the reason for: ImportError: cannot import name 'get_act_layer'. I am using Python 3.6.8 within Anaconda.

To Reproduce Steps to reproduce the behavior:

  1. Go to Python (v 3.6.8) within Anaconda
  2. Try to import the get_act_layer Monai utility using 'from monai.networks.layers import get_act_layer'.

Expected behavior I expected to be able to import the get_act_layer Monai utility by importing it as described in https://docs.monai.io/en/latest/networks.html.

Screenshots If applicable, add screenshots to help explain your problem.

Environment

Ensuring you use the relevant python executable, please paste the output of:

python -c 'import monai; monai.config.print_debug_info()'

================================ Printing MONAI config...

MONAI version: 0.5.3 Numpy version: 1.19.5 Pytorch version: 1.5.1 MONAI flags: HAS_EXT = False, USE_COMPILED = False MONAI rev id: d78c669c67e38ddfbe572f6a0438e9df0b8c65d7

Optional dependencies: Pytorch Ignite version: NOT INSTALLED or UNKNOWN VERSION. Nibabel version: 3.2.1 scikit-image version: 0.15.0 Pillow version: 6.0.0 Tensorboard version: 2.6.0a20210608 gdown version: NOT INSTALLED or UNKNOWN VERSION. TorchVision version: 0.6.1 ITK version: 5.1.2 tqdm version: 4.60.0 lmdb version: NOT INSTALLED or UNKNOWN VERSION. psutil version: 5.6.2

For details about installing the optional dependencies, please visit: https://docs.monai.io/en/latest/installation.html#installing-the-recommended-dependencies

================================ Printing system config...

System: Windows Win32 version: ('10', '10.0.19041', 'SP0', 'Multiprocessor Free') Platform: Windows-10-10.0.19041-SP0 Processor: Intel64 Family 6 Model 85 Stepping 4, GenuineIntel Machine: AMD64 Python version: 3.6.8 Process name: pythonw.exe Command: ['C:\Users\lh18\AppData\Local\Continuum\anaconda2\envs\lhv\pythonw.exe', '-m', 'spyder_kernels.console', '-f', 'C:\Users\lh18\AppData\Roaming\jupyter\runtime\kernel-c81488ef87bd.json'] Open files: [popenfile(path='C:\Users\lh18\AppData\Local\Spyder\QtWebEngine\Default\Visited Links', fd=-1), popenfile(path='C:\Users\lh18\.anaconda\navigator\scripts\lhv\spyder-out-2.txt', fd=-1), popenfile(path='C:\Users\lh18\.anaconda\navigator\scripts\lhv\spyder-err-2.txt', fd=-1), popenfile(path='C:\Users\lh18\AppData\Local\Temp\spyder\kernel-c81488ef87bd.stderr', fd=-1), popenfile(path='C:\Users\lh18\.ipython\profile_default\history.sqlite', fd=-1), popenfile(path='C:\Users\lh18\.anaconda\navigator\logs\navigator.log', fd=-1), popenfile(path='C:\Windows\System32\en-US\kernel32.dll.mui', fd=-1), popenfile(path='C:\Users\lh18\.anaconda\navigator\navigator.lock', fd=-1), popenfile(path='C:\Windows\System32\en-US\KernelBase.dll.mui', fd=-1)] Num physical CPUs: 4 Num logical CPUs: 8 Num usable CPUs: 8 CPU usage (%): [1.0, 0.6, 3.2, 0.5, 0.8, 0.6, 0.9, 0.3] CPU freq. (MHz): 3600 Load avg. in last 1, 5, 15 mins (%): [0.0, 0.0, 0.0] Disk usage (%): 73.7 Avg. sensor temp. (Celsius): UNKNOWN for given OS Total physical memory (GB): 31.7 Available memory (GB): 24.1 Used memory (GB): 7.6

================================ Printing GPU config...

Num GPUs: 1 Has CUDA: True CUDA version: 10.2 cuDNN enabled: True cuDNN version: 7605 Current device: 0 GPU 0 Name: Quadro P600 GPU 0 Is integrated: False GPU 0 Is multi GPU board: False GPU 0 Multi processor count: 3 GPU 0 Total memory (GB): 2.0 GPU 0 CUDA capability (maj.min): 6.1

Additional context Add any other context about the problem here.

Nic-Ma commented 3 years ago

I would suggest you to try the latest MONAI version.

Thanks.

LaiaHumbertVidan commented 3 years ago

It worked! Thank you!


From: Nic Ma @.> Sent: 05 November 2021 16:08 To: Project-MONAI/MONAI @.> Cc: Humbert-Vidan, Laia @.>; Author @.> Subject: Re: [Project-MONAI/MONAI] ImportError: cannot import name 'get_act_layer' (Issue #3275)

I would suggest you to try the latest MONAI version.

Thanks.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHubhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FProject-MONAI%2FMONAI%2Fissues%2F3275%23issuecomment-961975185&data=04%7C01%7Claia.humbert-vidan%40kcl.ac.uk%7C63ec4168218d4d1f0b1408d9a06e2ebc%7C8370cf1416f34c16b83c724071654356%7C0%7C0%7C637717217352185002%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=s%2BHyTxV4%2BT5WeCj%2BdWPZq74MqRdij4gz9if93e1mdVc%3D&reserved=0, or unsubscribehttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAU3BM3BN3BK6XOYEANDDAY3UKPXQJANCNFSM5HOASTMA&data=04%7C01%7Claia.humbert-vidan%40kcl.ac.uk%7C63ec4168218d4d1f0b1408d9a06e2ebc%7C8370cf1416f34c16b83c724071654356%7C0%7C0%7C637717217352194998%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=pu5qAIBf9LbBqRbMQRuvNWwHLgBRCw1sO4cQvedehRc%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7Claia.humbert-vidan%40kcl.ac.uk%7C63ec4168218d4d1f0b1408d9a06e2ebc%7C8370cf1416f34c16b83c724071654356%7C0%7C0%7C637717217352204992%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=IAL66kgcE9B3nfc%2FziAL8BIsRreZU5oW6gBjDvUb4eM%3D&reserved=0 or Androidhttps://eur03.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7Claia.humbert-vidan%40kcl.ac.uk%7C63ec4168218d4d1f0b1408d9a06e2ebc%7C8370cf1416f34c16b83c724071654356%7C0%7C0%7C637717217352204992%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C1000&sdata=1PbTsVEfS1V5M6D04GR6nbsB6iGj0M1PzR4k5ooWFdI%3D&reserved=0.