Install CNTK deep learning framework under Ubuntu20.04 system
1. Introduction to CNTK Framework
Computational Network Toolkit (CNTK) is an open source deep learning toolkit produced by Microsoft. According to the description of Microsoft developers, CNTK's performance is better than mainstream tools such as Caffe, Theano, and TensoFlow. It supports CPU and GPU modes, so there is no GPU, or the neural network is relatively small for experiments, just use the CPU version of CNTK to run it. Its open source homepage is on CNTK github, which describes the neural network as a directed graph structure, with leaf nodes representing inputs or network parameters, and other node calculation steps. It supports convolutional neural networks and recurrent neural networks.
The tutorial can refer to the following three aspects:
2. Installation
Some AMD graphics cards can also perform GPU acceleration. Based on the AMD ROCM framework , because NVIDIA graphics acceleration is used more in the market, I use NVIDIA graphics acceleration environment here, so first install CUDA and CUDNN environments. Specific installation process can refer to this blog post: Ubuntu install CUDA and CUDNN tutorials .
Since the Ubuntu20.04 default Python environment is Python3.8, the official website has detailed version on environmental needs.
It can be seen that we need to install a lower version of the Python environment. Here we have chosen the Python 3.6.8 environment. Download the source code package on the Python official website for installation.
Unzip the installation package, enter the installation folder, and install it
tar -xvf Python-3.6.8.tgz
cd Python-3.6.8
./configure
make
sudo make install
After a period of source code compilation, the Python environment can be installed successfully. Then create a soft connection according to the actual situation
sudo ln -s -f /usr/local/bin/python3.6 /usr/local/python3.6
sudo ln -s -f /usr/local/bin/pip3.6 /usr/local/pip3.6
Problems encountered
When compiling the source code, you can find that the _ssl
package is not found. There are many tutorials that say that you need to add --with-ssl
parameters when compiling the python source code to install, but this does not solve the problem, and errors will occur configure: WARNING: unrecognized options: --with-ssl
, namely Unrecognized option. If there is no ssl
package, an error will occur pip is configured with locations that require TLS/SSL
.
Reference blog post: python3 solves ModuleNotFoundError: No module named'_ssl' , but after modifying the blog post, the problem is not solved, and an error occurs during compilation
error: openssl/rsa.h: No such file or directory
So this did not fundamentally solve the problem. So I thought that the library file corresponding to openssl might be missing. At the same time, the tk library is missing when compiling the source code, so install it in Ubuntu
sudo apt-get install libssl-dev python3-tk
Recompile, you can install the corresponding installation package successfully. ssl module successfully installed
Now we can install the CNTK environment. Create a virtual environment
mkvirtualenv --python=/usr/bin/python3.6 cntk
Install cntk-gpu directly
pip install cntk-gpu
Or follow the official website to install:
pip install https://cntk.ai/PythonWheel/GPU/cntk_gpu-2.7.post1-cp36-cp36m-linux_x86_64.whl
This successfully installed CNTK's CUDA acceleration environment.
reference
[1] CNTK official website
[2] Python3 source code compilation and uninstallation method under Linux
[3] ubuntu 20.04 install python 3.6.8
[4] The Microsoft Cognitive Toolkit
[5] CNTK Setup