MXNet - Ubuntu安装

本文详细介绍了如何在Ubuntu 14.04/16.04环境下使用GPU安装MXNet深度学习框架的过程。包括安装必备组件如CUDA 8.0、cuDNN v5,配置环境变量,从源代码编译MXNet核心库及Python API等步骤。

MXNet - 安装

基于Ubuntu14.04/16.04,Python,GPU,Build from Sources

Prerequisites

  • CUDA8.0
  • cuDNN v5 for CUDA8.0
    确保添加CUDA安装路径到LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/local/cuda/lib64/:$LD_LIBRARY_PATH

编译 MXNnet核心库

从 C++ 源码编译 MXNet core shared library - libmxnet.so.

Minimum Requirements:
- GCC 4.8 or later to compile C++ 11
- GNU Make

# Step 1 Install build tools and git.
$ sudo apt-get update
$ sudo apt-get install -y build-essential git

# Step 2 Install OpenBLAS.
$ sudo apt-get install -y libopenblas-dev

# Step 3 Install OpenCV.
$ sudo apt-get install -y libopencv-dev

# Step 4 Download MXNet sources and build MXNet core shared library.
$ git clone --recursive https://github.com/dmlc/mxnet
$ cd mxnet
$ make -j $(nproc) USE_OPENCV=1 USE_BLAS=openblas USE_CUDA=1 USE_CUDA_PATH=/usr/local/cuda USE_CUDNN=1

编译 MXNet的Python API

# Step 1 Install prerequisites - python setup tools and numpy.
$ sudo apt-get install -y python-dev python-setuptools python-numpy

# Step 2 Build the MXNet Python binding.
$ cd python
$ sudo python setup.py install

# Step 3 Validate the installation by running simple MXNet code.
>>> import mxnet as mx
>>> a = mx.nd.ones((2, 3), mx.gpu()) # 在GPU上创建 2×3 矩阵
>>> b = a * 2 + 1 # 矩阵a各元素 ×2 + 1
>>> b.asnumpy()
array([[ 3.,  3.,  3.],
       [ 3.,  3.,  3.]], dtype=float32)
(d2l) C:\Windows\System32>pip install mxnet-cu101==1.7.0 -f https://dist.mxnet.io/python Looking in indexes: https://pypi.tuna.tsinghua.edu.cn/simple Looking in links: https://dist.mxnet.io/python DEPRECATION: Wheel filename 'mxnet-pi-1.5.0-py2.py3-none-any.whl' is not correctly normalised. Future versions of pip will raise the following error: Invalid wheel filename (invalid version): 'mxnet-pi-1.5.0-py2.py3-none-any' pip 25.3 will enforce this behaviour change. A possible replacement is to rename the wheel to use a correctly normalised name (this may require updating the version in the project metadata). Discussion can be found at https://github.com/pypa/pip/issues/12938 DEPRECATION: Wheel filename 'mxnet-raspi-1.5.0-py2.py3-none-any.whl' is not correctly normalised. Future versions of pip will raise the following error: Invalid wheel filename (invalid version): 'mxnet-raspi-1.5.0-py2.py3-none-any' pip 25.3 will enforce this behaviour change. A possible replacement is to rename the wheel to use a correctly normalised name (this may require updating the version in the project metadata). Discussion can be found at https://github.com/pypa/pip/issues/12938 Collecting mxnet-cu101==1.7.0 Using cached https://repo.mxnet.io/dist/python/cu101/mxnet_cu101-1.7.0-py2.py3-none-win_amd64.whl (718.3 MB) Requirement already satisfied: numpy<1.17.0,>=1.8.2 in d:\anaconda\envs\d2l\lib\site-packages (from mxnet-cu101==1.7.0) (1.16.6) Requirement already satisfied: requests<2.19.0,>=2.18.4 in d:\anaconda\envs\d2l\lib\site-packages (from mxnet-cu101==1.7.0) (2.18.4) INFO: pip is looking at multiple versions of mxnet-cu101 to determine which version is compatible with other requirements. This could take a while. ERROR: Could not find a version that satisfies the requirement graphviz<0.9.0,>=0.8.1 (from mxnet-cu101) (from versions: none) ERROR: No matching distribution found for graphviz<0.9.0,>=0.8.1
最新发布
06-08
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值