LoginSignup
1
1

More than 5 years have passed since last update.

Chainerでcupy.cuda.driver.CUDADriverError: CUDA_ERROR_INVALID_PTX: a PTX JIT compilation failedが出たときの対処法

Posted at

久しぶりにchainerを使ってモデルを組んでみたら

cupy.cuda.driver.CUDADriverError: CUDA_ERROR_INVALID_PTX: a PTX JIT compilation failed

が出た。。。

らしいが、それでも治らない場合はcupyのバージョンと、CUDAのバージョンがずれているということだ。
image.png
https://docs-cupy.chainer.org/en/latest/install.html

なので、まずcupyのバージョンとCUDAのバージョンをチェックしよう。

nvcc -V & pip freeze | grep cupy

image.png

自分はcupy-cuda100をダウンロードしてて、CUDA が9.1になっていた。
人によって、バージョン状況は異なると思うが、

  • cupy.cuda.driver.CUDADriverError: CUDA_ERROR_INVALID_PTX: a PTX JIT compilation failed
  • original error: libcublas.so.10.0: cannot open shared object file: No such file or directory

などのエラーが出ていれば、cupyとCUDAのバージョンミスマッチによるエラーであることの可能性があるので、以下の手順を試すと直るかもしれません(僕は直りました)。

1 複数バージョンのcupyがある場合は不要なバージョンをアンインストール(僕はcupy-cuda100だけにしました)。

pip uninstall cupy-cudaxxx

(CUDA10.0用のcupyをダウンロードする場合)
pip install cupy-cuda100

2 CUDA 10.0のダウンロード

3 CUDA 10.0へ切り替える
switch-cudaをダウンロードして、実行する。

git clone https://github.com/phohenecker/switch-cuda

cd switch-cuda

source switch-cuda 10.0

image.png

これでcupy とCUDAのバージョンがあうので上記のエラーなく実行できるはずである。

1
1
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
1
1