nvidia-docker镜像中tensorflow-gpu无法使用gpu

一、报错(docker容器中)

no NVIDIA GPU device is present: /dev/nvidia0 does not exist

在这里插入图片描述

二、解决(必须在已经安装好nvidia-docker前提下)

1. 检测 nvidia-docker(宿主机)

tpx@aiot-3000:~$ docker run --runtime=nvidia --rm nvidia/cuda:10.1-base nvidia-smi

在这里插入图片描述

2. suggestion-slover解决

  • As per the docs here and here, you have to add a “gpus” argument when creating a the docker container to have gpu support.
  • So you should start your container something like this. The “–gpus all” makes all the gpus available on the host to be visible to the container.
docker run -it  -d --gpus all  --restart=always  --name 【容器名】【镜像id】 /bin/bash

Also you can try running nvidia-smi on the tensorflow image to quickly check if gpu is accessible on the container.

docker run -it --rm --gpus all tensorflow/tensorflow:latest-gpu-jupyter nvidia-smi

三、检验容器中是否可以使用gpu加速tensorflow-gpu,Pytroch代码

>>> import tensorflow as ps
>>> print()
返回True,则配置完毕
>>>import torch
>>>print(torch.cuda.is_available())#检查gpu是否可用
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值