LoginSignup
0
0

PyTorch on Ryzen7 5700u

Last updated at Posted at 2024-05-08

Ryzen7 5700Uなど、CPU内蔵のGPUで、PyTorchを利用する

amdのcudaに相当するrocmのinstall方法は、対応のドライバーのインストールとruntime環境のinstallからなります

# Make the directory if it doesn't exist yet.
# This location is recommended by the distribution maintainers.
sudo mkdir --parents --mode=0755 /etc/apt/keyrings

# Download the key, convert the signing-key to a full
# keyring required by apt and store in the keyring directory
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | \
    gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/amdgpu/6.1/ubuntu jammy main" \
    | sudo tee /etc/apt/sources.list.d/amdgpu.list
sudo apt update
sudo apt install amdgpu-dkms
sudo reboot
sudo apt remove rocminfo rocm-smi rocm-device-libs
sudo apt install rocm
sudo tee --append /etc/ld.so.conf.d/rocm.conf <<EOF
/opt/rocm/lib
/opt/rocm/lib64
EOF
sudo ldconfig
.bashrc
export PATH=$PATH:/opt/rocm-6.1.0/bin
export HSA_OVERRIDE_GFX_VERSION=9.0.0
export HSA_ENABLE_SDMA=0

を追加

check

dkms status
rocminfo
clinfo

reinstall pytorch

python3 -m pip uninstall torch torchvision torchaudio

https://pytorch.org/get-started/locally/
を参考に

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/rocm6.0

trouble shoot

もし、rocminfoが、通常ユーザーで動かなかったら

$ ls -la /dev/kfd
crw-rw---- 1 root render 235, 0  5月  8 15:04 /dev/kfd

上は動いているときの状況です。

sudo usermod -aG render $USER
sudo usermod -aG video $USER

や、

sudo chmod g+rw /dev/kfd

などパーミッションの設定を

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0