ModuleNotFoundError: No module named 'tools.nnwrap'
Question:
I tried to install torch
using:
pip install torch
Installation started, but after a few seconds I got the error:
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
OS: Windows
Answers:
Anyone who is looking for the solution refer below:
It seems command to install torch not is working as expected, instead, you can try to install PyTorch using below command.
It’s working and solved my above-mentioned issue.
Run below command(for below-specified OS, package-manager, Language):
# for OS: Windows, package-manager: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
For another version/type of the software (OS, package, Language) installed, the command must be generated from the below-mentioned link.
https://pytorch.org/get-started/locally/
Also, look for the Python version in your IDE(If you are using PyCharm) from the terminal using the command: python. If it returns 32bit this could happen, instead install Python 64-bit.
Follow the instructions on https://pytorch.org/get-started/locally/
Choose Package “Pip” if you want to pip install
It will give you output such as
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp37-cp37m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp37-cp37m-win_amd64.whl
Edit: new install instructions from pytorch.org shows commands such as
pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html
For what it’s worth, on Windows 10 in Anaconda, the only command which worked for me was:
pip3 install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp37-cp37m-win_amd64.whl
I was getting the same error, then I found that the latest pytorch install requires CUDA 10.1, and once I installed that and the matching cuDNN, then this command line succeeded:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
For me this was fixed by checking my python version – I got this error with python 3.8, but the error went away when I downgraded to 3.7 (install instructions on the site only appear to go up to 3.7).
To install stable version of pytorch in windows 10 for pycharm, following command should work.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
How I fix it in Windows 10 (x64)
31 March 2020
-
Install CUDA from here: https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
- Version:
cuda_10.2.89_441.22_win10.exe
-
Use official website pytorch: https://pytorch.org/get-started/locally/
- This command in CMD:
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
-
In Anaconda3 I tried to use same website just change Package to conda:
- Command in jupyter notebook:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
- And after restart it does NOT work
- So I tried to use
pip
again in jupyter notebook: pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
- And it WORKS (if no, you can try to restart kernel):
Had to fix this at two locations:
DEV windows 10 machine:
CD to C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64Scripts
execute: conda install pytorch
DEV Windows MSSQL Server Database Python Services
CD to C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERPYTHON_SERVICESScripts
execute: pip3 install torch
This worked for Windows 10 using Python-3.x pip
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
For me (Python 3.7.6 x64 on Windows 10) this line worked:
pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
If you are using Anaconda (3.7) in windows then you need to install via .whl file.
Download .whl file from here:- https://download.pytorch.org/whl/torch_stable.html
then put in the working directory and install it using pip.
For my system, I have renamed anaconda’s pip to pip37
pip37 install torch-1.5.1+cpu-cp37-cp37m-win_amd64.whl
pip37 install torchvision-0.6.1+cpu-cp37-cp37m-win_amd64.whl
It will install Torch 1.5 & Torchvision 0.6.1 in your anaconda environment
Try this code. It worked for me-
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Try to uninstall python 3.8 32-bit and install 64-bit. it worked for me, then:
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
To whoever that has problem with torch installation: I think instead of following any of the commands posted here, you better first check pytorch official website (https://pytorch.org/). There you can easily specify all your setup info and get the proper command for download.
I got the same error and fixed it with:
pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
I’m on Windows 10, Python 3.8.6.
Alternatively:
- Go to https://pytorch.org/
- Scroll down to the center of the page where you’ll find a section with header "INSTALL PYTORCH"
- Select your preferences
- Copy the command to the right of where it says: "Run this Command:"
- Paste it on your termminal
- Click enter (I know, sounds obvious, but it wasn’t for my old self when I first started)
for the latest version of torch use the command below.
Without CUDA Support(CPU only):
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
With CUDA Support:
pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Check this link for the latest versions and get the command there itself from pytorch.
I tried to install torch
using:
pip install torch
Installation started, but after a few seconds I got the error:
from tools.nnwrap import generate_wrappers as generate_nn_wrappers
ModuleNotFoundError: No module named 'tools.nnwrap'
OS: Windows
Anyone who is looking for the solution refer below:
It seems command to install torch not is working as expected, instead, you can try to install PyTorch using below command.
It’s working and solved my above-mentioned issue.
Run below command(for below-specified OS, package-manager, Language):
# for OS: Windows, package-manager: pip, Language: python3.6 (below command is valid for only mentioned python 3.6)
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp36-cp36m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp36-cp36m-win_amd64.whl
For another version/type of the software (OS, package, Language) installed, the command must be generated from the below-mentioned link.
https://pytorch.org/get-started/locally/
Also, look for the Python version in your IDE(If you are using PyCharm) from the terminal using the command: python. If it returns 32bit this could happen, instead install Python 64-bit.
Follow the instructions on https://pytorch.org/get-started/locally/
Choose Package “Pip” if you want to pip install
It will give you output such as
pip3 install https://download.pytorch.org/whl/cu90/torch-1.1.0-cp37-cp37m-win_amd64.whl
pip3 install https://download.pytorch.org/whl/cu90/torchvision-0.3.0-cp37-cp37m-win_amd64.whl
Edit: new install instructions from pytorch.org shows commands such as
pip3 install torch===1.3.1 torchvision===0.4.2 -f https://download.pytorch.org/whl/torch_stable.html
For what it’s worth, on Windows 10 in Anaconda, the only command which worked for me was:
pip3 install https://download.pytorch.org/whl/cu90/torch-1.0.1-cp37-cp37m-win_amd64.whl
I was getting the same error, then I found that the latest pytorch install requires CUDA 10.1, and once I installed that and the matching cuDNN, then this command line succeeded:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
For me this was fixed by checking my python version – I got this error with python 3.8, but the error went away when I downgraded to 3.7 (install instructions on the site only appear to go up to 3.7).
To install stable version of pytorch in windows 10 for pycharm, following command should work.
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
How I fix it in Windows 10 (x64)
31 March 2020
-
Install CUDA from here:
https://developer.nvidia.com/cuda-downloads?target_os=Windows&target_arch=x86_64&target_version=10&target_type=exelocal
- Version:
cuda_10.2.89_441.22_win10.exe
- Version:
-
Use official website pytorch:
https://pytorch.org/get-started/locally/
- This command in CMD:
pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
- This command in CMD:
-
In Anaconda3 I tried to use same website just change Package to conda:
- Command in jupyter notebook:
conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
- And after restart it does NOT work
- So I tried to use
pip
again in jupyter notebook:pip install torch===1.4.0 torchvision===0.5.0 -f https://download.pytorch.org/whl/torch_stable.html
- And it WORKS (if no, you can try to restart kernel):
- Command in jupyter notebook:
Had to fix this at two locations:
DEV windows 10 machine:
CD to C:Program Files (x86)Microsoft Visual StudioSharedAnaconda3_64Scripts
execute: conda install pytorch
DEV Windows MSSQL Server Database Python Services
CD to C:Program FilesMicrosoft SQL ServerMSSQL14.MSSQLSERVERPYTHON_SERVICESScripts
execute: pip3 install torch
This worked for Windows 10 using Python-3.x pip
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
For me (Python 3.7.6 x64 on Windows 10) this line worked:
pip install torch==1.5.0 torchvision==0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
If you are using Anaconda (3.7) in windows then you need to install via .whl file.
Download .whl file from here:- https://download.pytorch.org/whl/torch_stable.html
then put in the working directory and install it using pip.
For my system, I have renamed anaconda’s pip to pip37
pip37 install torch-1.5.1+cpu-cp37-cp37m-win_amd64.whl
pip37 install torchvision-0.6.1+cpu-cp37-cp37m-win_amd64.whl
It will install Torch 1.5 & Torchvision 0.6.1 in your anaconda environment
Try this code. It worked for me-
pip install torch==1.4.0+cpu torchvision==0.5.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
Try to uninstall python 3.8 32-bit and install 64-bit. it worked for me, then:
pip3 install numpy
pip3 install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
To whoever that has problem with torch installation: I think instead of following any of the commands posted here, you better first check pytorch official website (https://pytorch.org/). There you can easily specify all your setup info and get the proper command for download.
I got the same error and fixed it with:
pip install torch===1.7.0 torchvision===0.8.1 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
I’m on Windows 10, Python 3.8.6.
Alternatively:
- Go to https://pytorch.org/
- Scroll down to the center of the page where you’ll find a section with header "INSTALL PYTORCH"
- Select your preferences
- Copy the command to the right of where it says: "Run this Command:"
- Paste it on your termminal
- Click enter (I know, sounds obvious, but it wasn’t for my old self when I first started)
for the latest version of torch use the command below.
Without CUDA Support(CPU only):
pip install torch==1.7.0+cpu torchvision==0.8.1+cpu torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
With CUDA Support:
pip install torch===1.7.0+cu110 torchvision===0.8.1+cu110 torchaudio===0.7.0 -f https://download.pytorch.org/whl/torch_stable.html
Check this link for the latest versions and get the command there itself from pytorch.