1
3

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.

機械学習の環境構築

Last updated at Posted at 2021-06-09

環境概要

  • Ubuntu 20.04 LTS Server
  • Python 3.8.5
  • pip3 20.0.2
  • pandas 1.2.4
  • TensorFlow 2.5.0
  • scikit-learn 0.24.2
  • CUDA 11.3.0
  • jupyter-notebook 6.4.0

Pythonライブラリのインストール

Ubuntu 20.04では,デフォルトでPython3.8.5がインストールされているので,Pythonのインストールは省略.

必要なPythonライブラリを順にインストールします.

$ sudo su
# apt-get update
# apt-get install python3-pip
# pip3 install tensorflow
# pip3 install pandas
# pip3 install scikit-learn
# pip3 install seaborn
# pip3 install notebook
# exit

jupyter notebookはデフォルトでは,localからしか接続できないので,
設定ファイルを作成し情報を追記します.
(0.0.0.0はすべてアクセスを許可する設定のため,セキュリティには,注意が必要)

$ jupyter notebook --generate-config
$ sed -i "$ a c.NotebookApp.ip = '0.0.0.0'" ~/.jupyter/jupyter_notebook_config.py

CUDAのインストール

GPU環境のため
CUDAのインストール

# sudo ubuntu-drivers autoinstall
# wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/cuda-ubuntu2004.pin
# mv cuda-ubuntu2004.pin /etc/apt/preferences.d/cuda-repository-pin-600
# apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/7fa2af80.pub
# add-apt-repository "deb https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2004/x86_64/ /"
# apt-get update
# apt-get -y install cuda
# echo "deb https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64 /" | sudo tee /etc/apt/sources.list.d/nvidia-ml.list
# sudo apt update
# sudo apt install libcudnn8-dev
# reboot

CUDAがすでにインストールされているなどでうまくいかない場合は先にアンインストールしておく

# apt-get --purge remove nvidia-*
# apt-get --purge remove cuda-*
.py
import tensorflow as tf
tf.test.is_gpu_available()

GPU環境が動作しているかチェック

1
3
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
1
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?