ubuntu18.04中基于Docker搭建tensorflow-gpu开发环境

前提条件就不多提啦,首先得装好nvidia驱动和Docker19以上版本,网上有很多教程。

尝试1:拉取现有的deepo镜像制作

deepo是一个囊括几乎所有深度学习框架的开源镜像,这里我们选择拉取一个tensorflow-gpu版本的,避免占用储存过大。

# 拉取
root@master:/home/hqc# docker pull ufoym/deepo:tensorflow-py36

# 查看该容器是否可见
root@master:/home/hqc# sudo docker run --rm --gpus all ufoym/deepo:tensorflow-py36 nvidia-smi
	+-----------------------------------------------------------------------------+
	| NVIDIA-SMI 495.44       Driver Version: 495.44       CUDA Version: 11.5     |
	|-------------------------------+----------------------+----------------------+
	| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
	| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
	|                               |                      |               MIG M. |
	|===============================+======================+======================|
	|   0  NVIDIA GeForce ...  Off  | 00000000:01:00.0 Off |                  N/A |
	| 23%   38C    P8     9W / 250W |     11MiB / 11178MiB |      0%      Default |
	|                               |                      |                  N/A |
	+-------------------------------+----------------------+----------------------+
	                                                                               
	+-----------------------------------------------------------------------------+
	| Processes:                                                                  |
	|  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
	|        ID   ID                                                   Usage      |
	|=============================================================================|
	+-----------------------------------------------------------------------------+
# 可见

# 进入容器
root@master:/home/hqc# docker run -gpus all -it ufoym/deepo:tensorflow-py36 bash
root@6ef50267dc04:/# nvidia-smi
	Tue Jun  7 05:59:34 2022       
	+-----------------------------------------------------------------------------+
	| NVIDIA-SMI 495.44       Driver Version: 495.44       CUDA Version: 11.5     |
	|-------------------------------+----------------------+------------
  • 3
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
可以按照以下步骤安装onnxruntime-gpu: 1. 确保你的GPU支持CUDA和cuDNN,并且已经安装了CUDA和cuDNN。 2. 安装依赖项: ``` sudo apt-get update sudo apt-get install -y git cmake build-essential libprotobuf-dev protobuf-compiler libprotobuf-dev libprotoc-dev libopencv-dev ``` 3. 克隆onnxruntime-gpu仓库: ``` git clone --recursive https://github.com/microsoft/onnxruntime.git ``` 4. 进入onnxruntime目录: ``` cd onnxruntime ``` 5. 创建build目录并进入: ``` mkdir build cd build ``` 6. 配置编译选项: ``` cmake .. -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr/local -Donnxruntime_USE_CUDA=ON -Donnxruntime_CUDA_HOME=/usr/local/cuda -Donnxruntime_CUDA_INCLUDE_DIRS=/usr/local/cuda/include -Donnxruntime_CUDA_LIB_DIRS=/usr/local/cuda/lib64 -Donnxruntime_USE_TENSORRT=OFF ``` 其,-Donnxruntime_USE_CUDA=ON表示使用CUDA,-Donnxruntime_CUDA_HOME、-Donnxruntime_CUDA_INCLUDE_DIRS、-Donnxruntime_CUDA_LIB_DIRS分别指定CUDA的安装路径和头文件路径、库文件路径。 7. 编译并安装: ``` make -j$(nproc) sudo make install ``` 这里使用了make -j$(nproc)来并行编译,可以加快编译速度。 8. 安装完毕后,可以测试一下onnxruntime-gpu是否正常工作: ``` cd ../tools/ci_build/github/linux/docker/scripts ./run_onnx_tests.sh -e gpu ``` 如果测试通过,则说明onnxruntime-gpu已经安装成功了。 注意:onnxruntime-gpu的安装可能会因为各种原因失败,需要根据具体错误信息进行调试。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值