2
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

no CUDA-capable device is detected

Last updated at Posted at 2020-10-20

2020/10/28 更新 エラーの解決策を見つけた。

#環境
linux
python3
gpu nvidia

#エラー
rayで__GPUを使用__し、並列処理をしていると以下のようなエラーがでる。

RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/pytorch_1591914855613/work/aten/src/THC/THCGeneral.cpp:47

#エラーの対処方法
上記のエラーは以下のようになっているであろうか。

 File "/home/user/anaconda3/envs/muzero/lib/python3.7/site-packages/torch/cuda/__init__.py", line 192, in _lazy_init
    torch._C._cuda_init()
RuntimeError: cuda runtime error (100) : no CUDA-capable device is detected at /opt/conda/conda-bld/pytorch_1591914855613/work/aten/src/THC/THCGeneral.cpp:47

このとき、/home/user/anaconda3/envs/muzero/lib/python3.7/site-packages/torch/cuda/__init__.pyのファイルを開く。
そして、以下のようにGPUの指定を行う。

r"""
This package adds support for CUDA tensor types, that implement the same
function as CPU tensors, but they utilize GPUs for computation.

It is lazily initialized, so you can always import it, and use
:func:`is_available()` to determine if your system supports CUDA.

:ref:`cuda-semantics` has more details about working with CUDA.
"""

import contextlib
import os
import torch
import traceback
import warnings
import threading
from typing import List, Optional, Tuple, Union
from torch._six import raise_from
from ._utils import _get_device_index, _dummy_type
from .streams import Stream, Event
from .. import device as _device
import torch._C

try:
    from torch._C import _cudart
except ImportError:
    _cudart = None

os.environ["CUDA_VISIBLE_DEVICES"]="0"
・
・
・

上記のように__os.environ["CUDA_VISIBLE_DEVICES"]="0"__を書く。

するとGPUが指定されてエラーがなくなる。
補足
私はCUDA:0をしようした例を書いた。
CUDA:1を使うならos.environ["CUDA_VISIBLE_DEVICES"]="0"と書く。

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?