I am new to pytorch and I am trying to understand how to enable CUDA in an anaconda environment.
I have created my conda env with the following commands
conda create --name env_name
conda activate env_name
conda install -c conda-forge -c pytorch python=3.7 pytorch torchvision cudatoolkit=10.1 opencv numpy pillow
Then I run the following file:
import torch
import torchvision
print("PyTorch Version: ",torch.__version__)
print("Torchvision Version: ",torchvision.__version__)
if torch.cuda.is_available():
print("if torch.cuda.is_available() returns TRUE")
else:
print("if torch.cuda.is_available() returns FALSE")
torch.zeros(1).cuda()
And I get
ython sources/torch_cuda_setup_check.py
PyTorch Version: 1.10.0
Torchvision Version: 0.10.0a0
if torch.cuda.is_available() returns FALSE
Traceback (most recent call last):
File "sources/torch_cuda_setup_check.py", line 12, in <module>
torch.zeros(1).cuda()
File "/home/fabrizioschiano/anaconda3/envs/deeplabv3finetuning/lib/python3.7/site-packages/torch/cuda/__init__.py", line 208, in _lazy_init
raise AssertionError("Torch not compiled with CUDA enabled")
AssertionError: Torch not compiled with CUDA enabled
Could you help me understanding how to install a version of torch which has CUDA enabled?
I am sure that my system has a GPU.
More details about my system can be found below.
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 |
+-----------------------------------------------------------------------------+