ModuleNotFoundError: No module named ‘tools.nnwrap’

Posted on

Question :

ModuleNotFoundError: No module named ‘tools.nnwrap’

I am trying to import a package “torch”.
For same, I tried to install it using pip command as below, installation even started but after few seconds it got error

below is the command that I executed

pip install torch

Error that I got:

from tools.nnwrap import generate_wrappers as generate_nn_wrappers
    ModuleNotFoundError: No module named 'tools.nnwrap'

OS: Windows.
IDE : pyCharm

I got the only link related to this issue but I was not able to interpret it.

https://www.gitmemory.com/torch

Asked By: Monu

||

Answer #1:

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/

Answered By: Monu

Answer #2:

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
Answered By: Monu

Answer #3:

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
Answered By: Slim

Answer #4:

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
Answered By: Demotte

Answer #5:

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

Answered By: Inna

Answer #6:

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).

Answered By: healer101

Answer #7:

How I fix it in Windows 10 (x64)

31 March 2020

  1. 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
  2. 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
  3. 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
    • enter image description here
    • 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
    • enter image description here
    • And it WORKS (if no, you can try to restart kernel):
    • enter image description here
Answered By: James Owers

Answer #8:

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
Answered By: Jackssn

Leave a Reply

Your email address will not be published. Required fields are marked *