AssertionError: Torch not compiled with CUDA enabled
Testin1234 opened this issue · comments
I'm trying to do neural style swapping, and for some reason, I keep getting the following errors.
AssertionError: Torch not compiled with CUDA enabled
File "c:\apps\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 260, in cuda
return self._apply(lambda t: t.cuda(device))
File "c:\apps\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 187, in _apply
module._apply(fn)
File "c:\apps\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 187, in _apply
module._apply(fn)
File "c:\apps\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 193, in _apply
param.data = fn(param.data)
File "c:\apps\Miniconda3\lib\site-packages\torch\nn\modules\module.py", line 260, in
return self.apply(lambda t: t.cuda(device))
File "c:\apps\Miniconda3\lib\site-packages\torch\cuda_init.py", line 161, in _lazy_init
check_driver()
File "c:\apps\Miniconda3\lib\site-packages\torch\cuda_init.py", line 75, in _check_driver
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
I recently reinstalled conda and this has just been completely broken for me.
cc @ezyang
How did you install pytorch? It sounds like you installed pytorch without CUDA support. https://pytorch.org/ has instructions for how to install pytorch with cuda support.
Shalom!
I am new to pytorch, and already installed pytorch in my Mac laptop.
trying to run the wsi_bert.py code, and get this error.
"""
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
"""
Please help.
Thx a lot!
Try this.
conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
Depending on what cuda version you have.
Note that unless you know otherwise, your Mac probably doesn't have an NVIDIA GPU on it.
For further support questions related to installation, please follow up on the forums https://discuss.pytorch.org/
I don't know where to raise an issue, but this continues to be a problem on Windows when Pytorch is installed without CUDA support even though it has been recently fixed for MacOS. Can someone help me?
Experiencing this problem on Windows as well.
I tried re-installing pytorch as per @swj0418 above,
conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
yet to no avail. Running this from with a Jupyter notebook under Anaconda on Windows 10 with an Nvidia1060 6GB & Intel i7.
Experiencing this problem on Windows as well.
I have the same question too. I think i need to modify the code, but i don't what to do.
Same here, installing as described on pytorch site (conda install pytorch torchvision cudatoolkit=10.1 -c pytorch
) yields (during installation):
cudatoolkit pkgs/main/win-64::cudatoolkit-10.1.243-h74a9793_0
pytorch pytorch/win-64::pytorch-1.5.0-py3.7_cpu_0
torchvision pytorch/win-64::torchvision-0.6.0-py37_cpu
Where there's clearly cpu already in the package names, which can be confirmed after installation:
pytorch 1.5.0 py3.7_cpu_0 [cpuonly] pytorch
p.s. CUDA 10.1 was completely installed before creating the env and installing pytorch
I had the same problem (Win10, CUDA installed prior to making conda env)
The option to install using pip worked for me (inside a miniconda env, python 3.7.7)
From the pytorch website:
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
I don't know where to raise an issue, but this continues to be a problem on Windows when Pytorch is installed without CUDA support even though it has been recently fixed for MacOS. Can someone help me?
Change code device = torch.device("cpu")
to device = torch.device("cuda")
Shalom!
I am new to pytorch, and already installed pytorch in my Mac laptop.
trying to run the wsi_bert.py code, and get this error.
"""
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
"""
Please help.
Thx a lot!
@Gailsunset I was running the same code from wsi_bert.py
, and although conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
from the reply right after didn't end up working out, just conda install cudatoolkit
led me to get past that issue.
In my case, I had cpuonly
package installed which needs to be removed.
In my case, I had
cpuonly
package installed which needs to be removed.
how did you delete it?
I had the same problem (Win10, CUDA installed prior to making conda env)
The option to install using pip worked for me (inside a miniconda env, python 3.7.7)
From the pytorch website:
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
Just confirming this approach worked for me; Windows 10, using Anaconda's CMD Terminal; CUDA v10
I don't know where to raise an issue, but this continues to be a problem on Windows when Pytorch is installed without CUDA support even though it has been recently fixed for MacOS. Can someone help me?
I'm having the same problem on an Ubuntu VM. No CUDA installed (because no GPU), and I am 100% sure it is the cpu-only version. I know because I have uninstalled and reinstalled many times (each time making sure all previous files are removed), trying pytorch 1.4, 1.5, and 1.6, all with corresponding torchvision versions. I've also tried editing the code to specify the whole torch.device="cpu" thing but the issue persists. I currently have torch=1.5 with cpu only and torchvision 0.6 installed and would be really grateful to anyone with suggestions.
Try this.
conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
Depending on what cuda version you have.
i have a rtx 2060 and it worked fine with this toolkit.
@Testin1234 are you resolve this one?
If you've ever ran pip install torch
without the -f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:
pip uninstall torch
pip cache purge
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
I had the same problem (Win10, CUDA installed prior to making conda env)
The option to install using pip worked for me (inside a miniconda env, python 3.7.7)
From the pytorch website:
pip install torch===1.5.0 torchvision===0.6.0 -f https://download.pytorch.org/whl/torch_stable.html
Thank you so much!!!!!!!!
I encountered the same problem, I think you should uninstall the cpu version of torch, and change it to the gpu version to solve it
But why does anybody have to install the Cuda version of PyTorch, if they don't have a GPU on their system? Shouldn't there be any other solution?
I tried the above commands, none of them work on my windiws-10.
Below step 1-5 are to solve in my case.
Make sure the cuda is available (True)
If False, we will have error. then we need to install the cuda first.
AssertionError: Torch not compiled with CUDA enabled
How TO: Install PyTorch (with GPU) in Window 10 (2021) by chinamatt.
https://www.youtube.com/watch?v=eodnCUzSeTk
print('torch.cuda.is_available():', torch.cuda.is_available())
Step 1:
before you get "torch.cuda.is_available(): True", we will have the error as below:
AssertionError: Torch not compiled with CUDA enabled
Step 2: Check your system have graphic card or not:
> dxdiag
tab "Dsiplay 1": Intel (R) UD=HD Graphcis Family
tab "Dispay 2": GeForce GTX 1060
GeForce (General Electronic Facsimil Optimized for Repair and Ceaseless Exploraiton)
GTX (Giga Texel Shader eXtrene)
https://developer.nvidia.com/cuda-downloads
1. Select Window > Window 10 > exe (network) to download
2. install cuda
Step 3:
Install Pytorch:
https://pytorch.org/get-started/locally/
select CUDA 11.1. The sintallation page is displayed:
run the following command
> conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
Type "y" to proceed. This will take long time. Take a break.
Step 4:
run the following command:
print('torch.cuda.is_available():', torch.cuda.is_available())
Run before you get "torch.cuda.is_available(): True"
Step 5:
import torch
t = t.cuda()
now is working.
when i run the following command: conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c conda-forge
i get the error: bash: conda: command not found
How I can I solve. Any suggestion are highly appreciated. Thanks
Hi In my case cofig: CUDA 11.2, windows 10, tensorflow 2.5, python 3.8.
ok. I tried though! WIll try again, let's see if i can fix it. Thank you very much!
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
This one worked for me.
if you are using torch on macOS or other PC without GPU, only cpu mode is available. You should find the code where torch device is set, like
torch.device(***)
Make sure it is set to :
torch.device("cpu")
Check out your CUDA version drivers
nvcc --version
It has to be matched with PyTorch supported CUDA drivers version.
go to Pytorch get started
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia
In case if your current cuda version drivers does not match. Eg. I had 11.3 and 11.0 installed. But the PyTorch currently supports only Cuda 11.1 . I had to re install CUDA 11.10 drivers
After that specify a PATH for using a correct version of CUDA drive-by editing ~/.bashrc and including
export PATH=/usr/local/cuda-11.1/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-11.1/lib64\${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
As soon as, you have done check again a current cuda version
nvcc --version
if they matched, create a new conda environment
conda create --name myenv
and install again
conda install pytorch torchvision torchaudio cudatoolkit=11.1 -c pytorch -c nvidia
check if Pytorch can see Cuda drivers
import torch
print(torch.__version__) # 1.9.0
print(torch.version.cuda) # 11.1
print(torch.cuda.is_available()) #True
When using the conda install command line from pytorch.org, I ended up with both pytorch-cpu 1.6.0
and pytorch 1.9.0
installed in the same conda env.
To fix it, I had to conda env remove
it, then create a new env with the same commandline without torchvision
and torchaudio
.
Then I installed those using conda install torchvision torchaudio -c pytorch -c nvidia
and it triggered an upgrade of cudatoolkit from 11.1.74
to 11.2.72
(but it seems to work).
If you are using conda
, you can check available PyTorch versions with conda search pytorch -c pytorch
On my end it shows
# Name Version Build Channel
pytorch 1.10.0 py3.6_cpu_0 pytorch
pytorch 1.10.0 py3.6_cuda10.2_cudnn7.6.5_0 pytorch
pytorch 1.10.0 py3.6_cuda11.1_cudnn8.0.5_0 pytorch
pytorch 1.10.0 py3.6_cuda11.3_cudnn8.2.0_0 pytorch
pytorch 1.10.0 py3.7_cpu_0 pytorch
pytorch 1.10.0 py3.7_cuda10.2_cudnn7.6.5_0 pytorch
pytorch 1.10.0 py3.7_cuda11.1_cudnn8.0.5_0 pytorch
pytorch 1.10.0 py3.7_cuda11.3_cudnn8.2.0_0 pytorch
pytorch 1.10.0 py3.8_cpu_0 pytorch
pytorch 1.10.0 py3.8_cuda10.2_cudnn7.6.5_0 pytorch
pytorch 1.10.0 py3.8_cuda11.1_cudnn8.0.5_0 pytorch
pytorch 1.10.0 py3.8_cuda11.3_cudnn8.2.0_0 pytorch
pytorch 1.10.0 py3.9_cpu_0 pytorch
pytorch 1.10.0 py3.9_cuda10.2_cudnn7.6.5_0 pytorch
pytorch 1.10.0 py3.9_cuda11.1_cudnn8.0.5_0 pytorch
pytorch 1.10.0 py3.9_cuda11.3_cudnn8.2.0_0 pytorch
It seems the latest PyTorch is only compiled on Cuda 10.2/11.1/11.3 for conda
. So if you try to install a cudatoolkit version that is different from these three, conda
will install CPU-only verison.
Finally solved this!
My problem:
Due to corporate restrictions I could not install from pytorch channel using -c pytorch
whereas I was using an index to install the version from. This version did not include the cuda version, but a CPU version. My restrictions are also the reason why my solution is very cumbersome.
My solution (I created an env for this):
- manually download the correct wheel from https://download.pytorch.org/whl/torch_stable.html, with the torch/cuda/python version corresponding to the dependencies from my previous step -> perhaps use conda list to check this
conda install python=x.x
(corresponding to the version of the wheel file you installed)conda install pip
(Conda install gave me troubles with the wheel)pip install PATH/TO/WHEEL
finally:
>>> torch.cuda.is_available() True
I had the same problem but still I cannot find a solution to my problem
I installed everything in my anaconda environment with:
conda install -c conda-forge -c pytorch python=3.7 pytorch torchvision cudatoolkit=10.1 opencv numpy pillow
Now I noticed that I installed the following packages (among others)
python conda-forge/linux-64::python-3.7.12-hb7a2778_100_cpython
python_abi conda-forge/linux-64::python_abi-3.7-2_cp37m
pytorch conda-forge/linux-64::pytorch-1.10.0-cpu_py37hf3cc979_0
pytorch-cpu conda-forge/linux-64::pytorch-cpu-1.10.0-cpu_py37h718b53a_0
qt conda-forge/linux-64::qt-5.12.9-hda022c4_4
Which means that the versions of pytorch installed are CPU only. Correct?
How can I install now a version of pytorch which is CUDA enabled?
Output details
Command:
conda install -c conda-forge -c pytorch python=3.7 pytorch torchvision cudatoolkit=10.1 opencv numpy pillow
Result:
Collecting package metadata (current_repodata.json): done
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.10.1
latest version: 4.10.3
Please update conda by running
$ conda update -n base -c defaults conda
## Package Plan ##
environment location: /home/fabrizioschiano/anaconda3/envs/deeplabv3finetuning
added / updated specs:
- cudatoolkit=10.1
- numpy
- opencv
- pillow
- python=3.7
- pytorch
- torchvision
The following packages will be downloaded:
package | build
---------------------------|-----------------
hdf5-1.12.1 |nompi_h2750804_102 3.5 MB conda-forge
libpq-13.5 | hd57d9b9_0 2.8 MB conda-forge
------------------------------------------------------------
Total: 6.3 MB
The following NEW packages will be INSTALLED:
_libgcc_mutex conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
_openmp_mutex conda-forge/linux-64::_openmp_mutex-4.5-1_llvm
alsa-lib conda-forge/linux-64::alsa-lib-1.2.3-h516909a_0
bzip2 conda-forge/linux-64::bzip2-1.0.8-h7f98852_4
c-ares conda-forge/linux-64::c-ares-1.18.1-h7f98852_0
ca-certificates conda-forge/linux-64::ca-certificates-2021.10.8-ha878542_0
cairo conda-forge/linux-64::cairo-1.16.0-h6cf1ce9_1008
cffi conda-forge/linux-64::cffi-1.15.0-py37h036bc23_0
cudatoolkit conda-forge/linux-64::cudatoolkit-10.1.243-h036e899_9
dbus conda-forge/linux-64::dbus-1.13.6-h48d8840_2
expat conda-forge/linux-64::expat-2.4.1-h9c3ff4c_0
ffmpeg conda-forge/linux-64::ffmpeg-4.3.2-hca11adc_1
fontconfig conda-forge/linux-64::fontconfig-2.13.1-hba837de_1005
freeglut conda-forge/linux-64::freeglut-3.2.1-h9c3ff4c_2
freetype conda-forge/linux-64::freetype-2.10.4-h0708190_1
future conda-forge/linux-64::future-0.18.2-py37h89c1867_4
gettext conda-forge/linux-64::gettext-0.19.8.1-h73d1719_1008
glib conda-forge/linux-64::glib-2.70.1-h780b84a_0
glib-tools conda-forge/linux-64::glib-tools-2.70.1-h780b84a_0
gmp conda-forge/linux-64::gmp-6.2.1-h58526e2_0
gnutls conda-forge/linux-64::gnutls-3.6.13-h85f3911_1
graphite2 conda-forge/linux-64::graphite2-1.3.13-h58526e2_1001
gst-plugins-base conda-forge/linux-64::gst-plugins-base-1.18.5-hf529b03_2
gstreamer conda-forge/linux-64::gstreamer-1.18.5-h9f60fe5_2
harfbuzz conda-forge/linux-64::harfbuzz-3.1.1-h83ec7ef_0
hdf5 conda-forge/linux-64::hdf5-1.12.1-nompi_h2750804_102
icu conda-forge/linux-64::icu-68.2-h9c3ff4c_0
jasper conda-forge/linux-64::jasper-2.0.33-ha77e612_0
jbig conda-forge/linux-64::jbig-2.1-h7f98852_2003
jpeg conda-forge/linux-64::jpeg-9d-h36c2ea0_0
krb5 conda-forge/linux-64::krb5-1.19.2-hcc1bbae_3
lame conda-forge/linux-64::lame-3.100-h7f98852_1001
lcms2 conda-forge/linux-64::lcms2-2.12-hddcbb42_0
ld_impl_linux-64 conda-forge/linux-64::ld_impl_linux-64-2.36.1-hea4e1c9_2
lerc conda-forge/linux-64::lerc-3.0-h9c3ff4c_0
libblas conda-forge/linux-64::libblas-3.9.0-12_linux64_mkl
libcblas conda-forge/linux-64::libcblas-3.9.0-12_linux64_mkl
libclang conda-forge/linux-64::libclang-11.1.0-default_ha53f305_1
libcurl conda-forge/linux-64::libcurl-7.80.0-h2574ce0_0
libdeflate conda-forge/linux-64::libdeflate-1.8-h7f98852_0
libedit conda-forge/linux-64::libedit-3.1.20191231-he28a2e2_2
libev conda-forge/linux-64::libev-4.33-h516909a_1
libevent conda-forge/linux-64::libevent-2.1.10-h9b69904_4
libffi conda-forge/linux-64::libffi-3.4.2-h7f98852_5
libgcc-ng conda-forge/linux-64::libgcc-ng-11.2.0-h1d223b6_11
libgfortran-ng conda-forge/linux-64::libgfortran-ng-11.2.0-h69a702a_11
libgfortran5 conda-forge/linux-64::libgfortran5-11.2.0-h5c6108e_11
libglib conda-forge/linux-64::libglib-2.70.1-h174f98d_0
libglu conda-forge/linux-64::libglu-9.0.0-he1b5a44_1001
libiconv conda-forge/linux-64::libiconv-1.16-h516909a_0
liblapack conda-forge/linux-64::liblapack-3.9.0-12_linux64_mkl
liblapacke conda-forge/linux-64::liblapacke-3.9.0-12_linux64_mkl
libllvm11 conda-forge/linux-64::libllvm11-11.1.0-hf817b99_2
libnghttp2 conda-forge/linux-64::libnghttp2-1.43.0-h812cca2_1
libnsl conda-forge/linux-64::libnsl-2.0.0-h7f98852_0
libogg conda-forge/linux-64::libogg-1.3.4-h7f98852_1
libopencv conda-forge/linux-64::libopencv-4.5.3-py37hbfc4018_5
libopus conda-forge/linux-64::libopus-1.3.1-h7f98852_1
libpng conda-forge/linux-64::libpng-1.6.37-h21135ba_2
libpq conda-forge/linux-64::libpq-13.5-hd57d9b9_0
libprotobuf conda-forge/linux-64::libprotobuf-3.18.1-h780b84a_0
libssh2 conda-forge/linux-64::libssh2-1.10.0-ha56f1ee_2
libstdcxx-ng conda-forge/linux-64::libstdcxx-ng-11.2.0-he4da1e4_11
libtiff conda-forge/linux-64::libtiff-4.3.0-h6f004c6_2
libuuid conda-forge/linux-64::libuuid-2.32.1-h7f98852_1000
libvorbis conda-forge/linux-64::libvorbis-1.3.7-h9c3ff4c_0
libwebp-base conda-forge/linux-64::libwebp-base-1.2.1-h7f98852_0
libxcb conda-forge/linux-64::libxcb-1.13-h7f98852_1004
libxkbcommon conda-forge/linux-64::libxkbcommon-1.0.3-he3ba5ed_0
libxml2 conda-forge/linux-64::libxml2-2.9.12-h72842e0_0
libzlib conda-forge/linux-64::libzlib-1.2.11-h36c2ea0_1013
llvm-openmp conda-forge/linux-64::llvm-openmp-12.0.1-h4bd325d_1
lz4-c conda-forge/linux-64::lz4-c-1.9.3-h9c3ff4c_1
mkl conda-forge/linux-64::mkl-2021.4.0-h8d4b97c_729
mysql-common conda-forge/linux-64::mysql-common-8.0.27-ha770c72_1
mysql-libs conda-forge/linux-64::mysql-libs-8.0.27-hfa10184_1
ncurses conda-forge/linux-64::ncurses-6.2-h58526e2_4
nettle conda-forge/linux-64::nettle-3.6-he412f7d_0
ninja conda-forge/linux-64::ninja-1.10.2-h4bd325d_1
nspr conda-forge/linux-64::nspr-4.32-h9c3ff4c_1
nss conda-forge/linux-64::nss-3.72-hb5efdd6_0
numpy conda-forge/linux-64::numpy-1.21.4-py37h31617e3_0
olefile conda-forge/noarch::olefile-0.46-pyh9f0ad1d_1
opencv conda-forge/linux-64::opencv-4.5.3-py37h89c1867_5
openh264 conda-forge/linux-64::openh264-2.1.1-h780b84a_0
openjpeg conda-forge/linux-64::openjpeg-2.4.0-hb52868f_1
openssl conda-forge/linux-64::openssl-1.1.1l-h7f98852_0
pcre conda-forge/linux-64::pcre-8.45-h9c3ff4c_0
pillow conda-forge/linux-64::pillow-8.4.0-py37h0f21c89_0
pip conda-forge/noarch::pip-21.3.1-pyhd8ed1ab_0
pixman conda-forge/linux-64::pixman-0.40.0-h36c2ea0_0
pthread-stubs conda-forge/linux-64::pthread-stubs-0.4-h36c2ea0_1001
py-opencv conda-forge/linux-64::py-opencv-4.5.3-py37h6531663_5
pycparser conda-forge/noarch::pycparser-2.21-pyhd8ed1ab_0
python conda-forge/linux-64::python-3.7.12-hb7a2778_100_cpython
python_abi conda-forge/linux-64::python_abi-3.7-2_cp37m
pytorch conda-forge/linux-64::pytorch-1.10.0-cpu_py37hf3cc979_0
pytorch-cpu conda-forge/linux-64::pytorch-cpu-1.10.0-cpu_py37h718b53a_0
qt conda-forge/linux-64::qt-5.12.9-hda022c4_4
readline conda-forge/linux-64::readline-8.1-h46c0cb4_0
setuptools conda-forge/linux-64::setuptools-59.2.0-py37h89c1867_0
sleef conda-forge/linux-64::sleef-3.5.1-h9b69904_2
sqlite conda-forge/linux-64::sqlite-3.36.0-h9cd32fc_2
tbb conda-forge/linux-64::tbb-2021.4.0-h4bd325d_1
tk conda-forge/linux-64::tk-8.6.11-h27826a3_1
torchvision conda-forge/linux-64::torchvision-0.10.1-py37h9e046cd_0_cpu
typing_extensions conda-forge/noarch::typing_extensions-4.0.0-pyha770c72_0
wheel conda-forge/noarch::wheel-0.37.0-pyhd8ed1ab_1
x264 conda-forge/linux-64::x264-1!161.3030-h7f98852_1
xorg-fixesproto conda-forge/linux-64::xorg-fixesproto-5.0-h7f98852_1002
xorg-inputproto conda-forge/linux-64::xorg-inputproto-2.3.2-h7f98852_1002
xorg-kbproto conda-forge/linux-64::xorg-kbproto-1.0.7-h7f98852_1002
xorg-libice conda-forge/linux-64::xorg-libice-1.0.10-h7f98852_0
xorg-libsm conda-forge/linux-64::xorg-libsm-1.2.3-hd9c2040_1000
xorg-libx11 conda-forge/linux-64::xorg-libx11-1.7.2-h7f98852_0
xorg-libxau conda-forge/linux-64::xorg-libxau-1.0.9-h7f98852_0
xorg-libxdmcp conda-forge/linux-64::xorg-libxdmcp-1.1.3-h7f98852_0
xorg-libxext conda-forge/linux-64::xorg-libxext-1.3.4-h7f98852_1
xorg-libxfixes conda-forge/linux-64::xorg-libxfixes-5.0.3-h7f98852_1004
xorg-libxi conda-forge/linux-64::xorg-libxi-1.7.10-h7f98852_0
xorg-libxrender conda-forge/linux-64::xorg-libxrender-0.9.10-h7f98852_1003
xorg-renderproto conda-forge/linux-64::xorg-renderproto-0.11.1-h7f98852_1002
xorg-xextproto conda-forge/linux-64::xorg-xextproto-7.3.0-h7f98852_1002
xorg-xproto conda-forge/linux-64::xorg-xproto-7.0.31-h7f98852_1007
xz conda-forge/linux-64::xz-5.2.5-h516909a_1
zlib conda-forge/linux-64::zlib-1.2.11-h36c2ea0_1013
zstd conda-forge/linux-64::zstd-1.5.0-ha95c52a_0
Proceed ([y]/n)? y
Downloading and Extracting Packages
hdf5-1.12.1 | 3.5 MB | ################################################################################################################################################## | 100%
libpq-13.5 | 2.8 MB | ################################################################################################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: | By downloading and using the CUDA Toolkit conda packages, you accept the terms and conditions of the CUDA End User License Agreement (EULA): https://docs.nvidia.com/cuda/eula/index.html
done
Details of my system
The command:
nvcc --version
gives the following output
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:07:16_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
The command:
nvidia-smi
gives the following output
Tue Nov 23 17:44:11 2021
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.82.00 Driver Version: 470.82.00 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| GPU Name Persistence-M| Bus-Id Disp.A | Volatile Uncorr. ECC |
| Fan Temp Perf Pwr:Usage/Cap| Memory-Usage | GPU-Util Compute M. |
| | | MIG M. |
|===============================+======================+======================|
| 0 NVIDIA GeForce ... Off | 00000000:01:00.0 On | N/A |
| N/A 54C P0 25W / N/A | 833MiB / 7973MiB | 1% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| 0 N/A N/A 1082 G /usr/lib/xorg/Xorg 102MiB |
| 0 N/A N/A 1693 G /usr/lib/xorg/Xorg 405MiB |
| 0 N/A N/A 1823 G /usr/bin/gnome-shell 130MiB |
| 0 N/A N/A 2306 G ...AAAAAAAAA= --shared-files 139MiB |
| 0 N/A N/A 4719 G .../debug.log --shared-files 2MiB |
| 0 N/A N/A 13922 G ...AAAAAAAAA= --shared-files 37MiB |
+-----------------------------------------------------------------------------+
I had the same problem but still I cannot find a solution to my problem
I installed everything in my anaconda environment with:
conda install -c conda-forge -c pytorch python=3.7 pytorch torchvision cudatoolkit=10.1 opencv numpy pillow
Now I noticed that I installed the following packages (among others)
python conda-forge/linux-64::python-3.7.12-hb7a2778_100_cpython python_abi conda-forge/linux-64::python_abi-3.7-2_cp37m pytorch conda-forge/linux-64::pytorch-1.10.0-cpu_py37hf3cc979_0 pytorch-cpu conda-forge/linux-64::pytorch-cpu-1.10.0-cpu_py37h718b53a_0 qt conda-forge/linux-64::qt-5.12.9-hda022c4_4
Which means that the versions of pytorch installed are CPU only. Correct?
How can I install now a version of pytorch which is CUDA enabled?
Output details
Details of my system
I think the latest Pytorch pre-built that supports CUDA 10.1 is Pytorch 1.8.1. So if you want Pytorch to work with CUDA 10.1, you either need to install the Pytorch 1.8.1 (or earlier), or compile Pytorch from source.
Thanks @qysnn for your answer.
In the end I switched from Conda to virtualenv and it worked at the first try.
I created my virtualenv with virtualenv virtualenv_name
Then I did
workon virtualenv_name
then, I installed pytorch as it is specified on the official pytorch website (but selecting pip instead of conda) as package manager (https://pytorch.org/get-started/locally/).
conda install pytorch torchvision torchaudio cudatoolkit=11.3 -c pytorch
This worked for me and now I have a CUDA-enabled version of pytorch on my machine.
None of the above solutions worked for me. I finally got it run by using the following line:
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
Windows 10:
I figured it out by making a fresh conda environment with python=3.7
Then,
Because pytorch GPU only works with select cuda versions (11.1, 11.3, 10.2)
conda install -c conda-forge cudatoolkit=11.3 cudnn=8.2.0
Install pytorch from pytorch channel
conda install pytorch -c pytorch
When using the conda install command line from pytorch.org, I ended up with both
pytorch-cpu 1.6.0
andpytorch 1.9.0
installed in the same conda env.To fix it, I had to
conda env remove
it, then create a new env with the same commandline withouttorchvision
andtorchaudio
.Then I installed those using
conda install torchvision torchaudio -c pytorch -c nvidia
and it triggered an upgrade of cudatoolkit from11.1.74
to11.2.72
(but it seems to work).
I used this on Manjaro 21.2, Miniconda3. This works perfectly!
How to solve this If I don't have GPU on my machine?
Hi may i know what is the command for non-conda versiosn of python ?
With regards to
conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
Is it simply
pip install torch+cu90 torchvision+cu90
for cuda 9.0 ?
@mzhadigerov i think if you dont have a GPU, you wont be able to use CUDA at all. Since CUDA is something that comes with NVIDIA GPUs
@mzhadigerov i think if you dont have a GPU, you wont be able to use CUDA at all. Since CUDA is something that comes with NVIDIA GPUs
Yes, youu need to have a NVIDIA GPU to be able to use CUDA. PyTorch-CPU will work fine.
Hi may i know what is the command for non-conda versiosn of python ? With regards to
conda install -c pytorch torchvision cudatoolkit=10.1 pytorch
Is it simply pip install torch+cu90 torchvision+cu90 for cuda 9.0 ?
Please refer to PyTorch installation page for the command of the appropriate PyTorch version.
None of the above solutions worked for me. I finally got it run by using the following line:
device = torch.device("cuda") if torch.cuda.is_available() else torch.device("cpu")
yah its work coz it dose not use GPU hahhaah
That's weird, because I used to do
torch.device("cpu")
before and it didn't work, but now it works
“Torch not compiled with CUDA enabled. ”
Recently I came across the same problem and fortunately I fixed it in the end. As for me, the troublesome problem occured when I deployed inappropriate versions of Cuda & Torch, and here is my solution:
- Note that my project works on Linux.
- I check my Nvidia & Cuda version on Linux through a simple command
nvidia-smi
. - Log in to CUDA Toolkit and Corresponding Driver Versions to check whether the version of Nvidia & Cuda installed is matchable or not. If not, probably you should reset Cuda to make it right.
- Log in to Previously Pytorch Versions to get a right command to download the correct version of Torch for the specific Cuda.
- For example, my server is driven by NVIDIA-SMI 418.43, so Cuda version 10.1 is matchable. The command for linux to download a matchable Torch(I want the version 1.5.0) should be
pip install torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html
. - Hope that it's helpful for you.
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
Ah, perfect. Thank you very much.
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
It worked, thanx!
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
Tried many fixes to no avail. This, however, worked. Thanks.
I had the same error message after installing PyTorch with the exact command they give as of now:
conda install pytorch torchvision torchaudio pytorch-cuda=11.6 -c pytorch -c nvidia
In my case, simply uninstalling and then reinstalling pytorch with my CUDA version worked for me.
- Run the command
conda remove pytorch torchvision torchaudio cudatoolkit
- Check your CUDA version the
nvcc --version
command. I have the11.7
- Install the pytorch that matches your CUDA version
conda install pytorch torchvision torchaudio pytorch-cuda=11.7 -c pytorch -c nvidia
Note: you can get from the Get Started Page
I had the same issue on Linux. I tried almost all the solutions proposed here, but none worked. Finally, I could solve my problem by first uninstalling Torch with pip uninstall torch
, and then reinstalling it with Wheel:
pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102
Then, I got the following, which confirmed that Torch was successfully compiled with CUDA enabled:
>>> import torch
>>> torch.__version__
'1.12.1+cu102'
>>> torch.zeros(1).cuda()
tensor([0.], device='cuda:0')
>>> torch.cuda.is_available()
True
For me it is very weird, it worked one day, and the next one(without installing nor configuring anything) it started to raise this problem, I'm not sure what happened but just the day before I was succesfully using cuda and my GPUs
what if i want to use the CPU version only why am i having issues with this assertion cuda enabled?
Hi,
I have M2 max chip MacOS with 12 CPU, 38 GPU. I am getting this error :“Torch not compiled with CUDA enabled”. May I ask your help please? Thanks
in DragGAN code, my idea,
device = F.device
...
# points.append(torch.tensor([i, j]).float().cuda())
points.append(torch.tensor([i, j]).float().to(device))
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
Tried many fixes to no avail. This, however, worked. Thanks.
This worked for me, thanks!
pip uninstall torch
pip cache purge
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
I had the same problem and the issue is fixed with the above solution.
Just run each command separately and it should solve your problem if it is the same as my problem.
👍 😃
Thank you @Mwni
looks like the mac build has been torched for some time.
(the above fix didnt work)
To get cuda version run below command
nvidia-smi
or
nvcc --version
as mentioned above then below command works for me:
conda install -c pytorch torchvision cudatoolkit=replace_your_cuda_version_here
pytorch
and after that running below commands solved my issue.
pip uninstall torch
pip cache purge
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
I had the same issue on Linux. I tried almost all the solutions proposed here, but none worked. Finally, I could solve my problem by first uninstalling Torch with
pip uninstall torch
, and then reinstalling it with Wheel:
pip install torch==1.12.1+cu102 torchvision==0.13.1+cu102 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu102
Then, I got the following, which confirmed that Torch was successfully compiled with CUDA enabled:
>>> import torch >>> torch.__version__ '1.12.1+cu102' >>> torch.zeros(1).cuda() tensor([0.], device='cuda:0') >>> torch.cuda.is_available() True
Many thanks for the solution, that's the only solution that worked on my linux machine as well.
Although I'm getting RuntimeError: CUDA error: invalid device function
when using nn.parallel.DistributedDataParallel
, does anyone else had it? any ideas?
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
This worked like a charm, Thank you !!!
Hi, I have M2 max chip MacOS with 12 CPU, 38 GPU. I am getting this error :“Torch not compiled with CUDA enabled”. May I ask your help please? Thanks
I heve the same issue in same pc
Hi, I have M2 max chip MacOS with 12 CPU, 38 GPU. I am getting this error :“Torch not compiled with CUDA enabled”. May I ask your help please? Thanks
I heve the same issue in same pc
you can set runtime mode to resolve this issue
You need to make sure that your cuda driver (downloaded at https://developer.nvidia.com/cuda-downloads) matches with the pytorch-cuda library version that you install with python.
For example, the current snippet at the official pytorch site is:
conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia
So, you need to have the 11.8 version of cuda downloaded from nvidia official website and installed.
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
如果您曾经在
pip install torch
没有-f https://download.pytorch.org/whl/torch_stable.html
参数的情况下运行过,那么您的 pip 缓存中很可能有损坏的仅 cpu 版本。无论你做什么重新安装,都没关系,因为 pip 只会从缓存中提取相同的错误版本。解决:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
thank you!!!!!
pip uninstall torch
pip cache purge
pip install torch -f https://download.pytorch.org/whl/torch_stable.html
I had the same problem and the issue is fixed with the above solution. Just run each command separately and it should solve your problem if it is the same as my problem. 👍 😃 Thank you @Mwni
thank you so much it works for me :)
I am getting the same error. My laptop doesn't have a dedicated Nvidia GPU. How can I resolve this? Is there any solution?
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
This one worked for me too! Thanks
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
this didn't work on my mac and now my torch is broken saying module not found but already satisfied so thanks a lot for this
How did you install pytorch? It sounds like you installed pytorch without CUDA support. https://pytorch.org/ has instructions for how to install pytorch with cuda support.
I also encountered the same error, this method is worked..
If you've ever ran
pip install torch
without the-f https://download.pytorch.org/whl/torch_stable.html
argument, chances are, you have the corrupt cpu only version in your pip cache. whatever reinstall you do, doesn't matter because pip will just pull the same bad version from cache. to solve:pip uninstall torch pip cache purge pip install torch -f https://download.pytorch.org/whl/torch_stable.html
This fixed my problem when encountering this issue while using DeepLabCut (DLC).
I use in conda env., reinstall it by commands and solved it.
e.g: conda install pytorch torchvision torchaudio pytorch-cuda=12.1 -c pytorch -c nvidia
pytorch-cuda depends you version.
device = torch.device("cuda")
This happens once you install pytorch using conda. Instead, install it using:
pip install torch