Skip to content

Instantly share code, notes, and snippets.

@JihoChoi
Last active September 3, 2023 13:42
Show Gist options
  • Save JihoChoi/06f73fe42ae9eba417176acb34404b98 to your computer and use it in GitHub Desktop.
Save JihoChoi/06f73fe42ae9eba417176acb34404b98 to your computer and use it in GitHub Desktop.
# Install
- https://developer.nvidia.com/
- https://youtu.be/UhuK9ShIpf8
nvidia-smi
sudo nvidia-persistenced --persistence-mode # when nvidia-smi hand
lshw -class display
lspci | grep -i nvidia
sudo vim /etc/profile.d/cuda.sh
# append
- export PATH=$PATH:/usr/local/cuda/bin
- export CUDADIR=/usr/local/cuda
sudo chmod +x /etc/profile.d/cuda.sh
sudo vim /etc/ld.so.conf
# append
- /usr/local/cuda/lib64
# reboot
nvcc --version
➜ ~ python3 --version
Python 3.6.8
➜ ~ nvcc --version
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
# https://pytorch.org/get-started/locally/
>>> import torch
>>> torch.__version__
'1.3.0'
>>> torch.version.cuda
'10.1.243'
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x7f50f21d22b0>
>>> torch.cuda.device_count()
1
>>> torch.cuda.get_device_name(0)
'GeForce GTX 1060 6GB'
>>> torch.cuda.is_available()
True
export PATH=/usr/local/cuda-10.2/bin:$PATH
nvidia-smi
nvcc --version
nvcc --version
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Wed_Oct_23_19:24:38_PDT_2019
Cuda compilation tools, release 10.2, V10.2.89
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.version.cuda
'10.1.243'
>>> torch.cuda.device_count()
File "<stdin>", line 1
torch.cuda.device_count()
^
IndentationError: unexpected indent
>>> torch.cuda.device_count()
8
>>> exit
Use exit() or Ctrl-D (i.e. EOF) to exit
>>> exit()
(env) ➜ point-cloud-inference git:(master) ✗ python
Python 3.6.9 (default, Nov 7 2019, 10:44:02)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import torch
>>> torch.__version__
'1.3.1'
>>> torch.version.cuda
'10.1.243'
>>> torch.cuda.device_count()
8
>>> torch.cuda.device(0)
<torch.cuda.device object at 0x7feac34b8320>
>>> torch.cuda.get_device_name(0)
'GeForce GTX 1080 Ti'
>>> torch.cuda.is_available()
True
# -------------------------
# Errors, Uninstall, Remove
# -------------------------
sudo dpkg --configure -a
Errors were encountered while processing:
cuda-libraries-dev-10-2
cuda-visual-tools-10-2
cuda-samples-10-2
cuda-toolkit-10-2
cuda-10-2
cuda-documentation-10-2
cuda
cuda-tools-10-2
sudo apt-get remove --dry-run cuda
# software center
gnome-software
software-properties-gtk
sudo ln -s cuda-10.1 cuda
sudo apt-get install --fix-broken
// https://appuals.com/fix-unmet-dependencies-error-ubuntu/
sudo apt-get autoremove --purge cuda
sudo add-apt-repository --remove ppa:someppa/ppa
sudo apt-get clean
sudo apt-get autoclean
sudo prime-select intel
sudo apt-get -f install
# REMOVE unmet dependencies
bash
sudo apt-get --purge remove 'cuda*'
sudo apt-get autoremove --purge 'cuda*'
sudo rm -rf /usr/local/cuda
# sudo rm -rf /usr/local/cuda-10.0
dpkg --audit
sudo dpkg --remove --force-all cuda-libraries-dev-10-2
@JihoChoi
Copy link
Author

JihoChoi commented Sep 3, 2023

Setup

# -------------------------------------------------
#         SETUP - Ubuntu 22.04 (2023.09.00)
# -------------------------------------------------

# ---------------------
#     CHECK VERSION
# ---------------------

$ python3 --version
# > Python 3.10.12

$ pip3 --version
# > pip 22.0.2 from /home/.../env/lib/python3.10/site-packages/pip (python 3.10)

$ lsb_release -a
# > No LSB modules are available.
# > Distributor ID: Ubuntu
# > Description: Ubuntu 22.04.3 LTS
# > Release: 22.04
# > Codename: jammy

$ nvidia-smi
# > NVIDIA-SMI 535.86.05
# > Driver Version: 535.86.05
# > CUDA Version: 12.2


# -------------------------------
#     INSTALL CUDA + ADD PATH
# -------------------------------

# (x) $ sudo apt install nvidia-cuda-toolkit
# (o) -> https://developer.nvidia.com
#     -> $ wget https://developer.download.nvidia.com/compute/cuda/12.2.2/local_installers/cuda_12.2.2_535.104.05_linux.run
#     -> $ sudo sh cuda_11.8.0_520.61.05_linux.run
#     -> $ sudo sh cuda_12.2.2_535.104.05_linux.run

export PATH="/usr/local/cuda-12.2/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-12.2/lib64:$LD_LIBRARY_PATH"
# export CUDADIR="/usr/local/cuda"

$ nvcc --version

# -----------------------------------
#     SETUP PYTHON VENV + PYTORCH
# -----------------------------------

$ sudo apt-get install python3-venv
$ cd ./dynamic-gcn-public
$ python3 -m venv env
$ source ./env/bin/activate

# https://pytorch.org/get-started/locally/
$ pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
import torch
torch.cuda.is_available()      # True
torch.cuda.device_count()      # 2
torch.cuda.device(1)           # <torch.cuda.device object at 0x0000>
torch.cuda.get_device_name(1)  # 'NVIDIA GeForce RTX 3070'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment