The last modifications of this post were around 3 years ago, some information may be outdated!
This is a draft, the content is not complete and of poor quality!
This note is for things with PyTorch. Personal notes only.
- Verify that your computer has a graphic card (NVIDIA):
lspci -nn | grep '\[03'
- Check the CUDA version on Ubuntu:
nvidia-smi. If have problems, check this note.
- Install the lates version: here.
Problem with CUDA version
For example, need to install corresponding versions:
pip3 install -U torch==1.2.0
pip3 install -U torchvision==0.4.0
pip3 install -U "pillow<7"
Another option (worked on XPS 15 7950):
nvcc --version is
NVIDIA too old
The NVIDIA driver on your system is too old (found version 10010).
From this website, problem is solved by
- Switching from
- Restart the computer.
It works on Dell XPS 7950 whose GPU is NVIDIA GTX 1650.
🔅 RuntimeError: cuda runtime error (804) : forward compatibility was attempted on non supported HW at /pytorch/aten/src/THC/THCGeneral.cpp:47 (after update system including nvdia-cli, maybe): check this note.
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
print('cuda is available? ', torch.cuda.is_available())
print('device_count: ', torch.cuda.device_count())
print('current device: ', torch.cuda.current_device())
print('device name: ', torch.cuda.get_device_name(0))
# Determine supported device
device = torch.device('cuda:0') # or something else
device = torch.device('cpu') # don't have GPU
Convert DataFrame / Series to Tensor
device = get_device() # see other section