サーバーの使用時に発生する可能性のあるいくつかの問題
1. GPU モデルとドライバーのバージョンの関係を確認するにはどうすればよいですか?
新しい CUDA ドライバーをインストールする場合、現在の GPU に対応するドライバーのバージョンを見つける必要があります。これはhttps://www.nvidia.com/Download/Find.aspx?lang=en-us
ログインすることで取得できます。ログイン インターフェイスは次のとおりです。
対応する GPU モデルを入力して、対応するドライバーを取得します。
2. 現在のサーバー カーネルのバージョンを確認するにはどうすればよいですか?
1) カーネルリストを表示します。
$ sudo dpkg --get-selections | grep linux-image
linux-image-5.0.0-23-generic deinstall
linux-image-5.0.0-25-generic deinstall
linux-image-5.0.0-27-generic deinstall
linux-image-5.0.0-29-generic deinstall
linux-image-5.0.0-31-generic deinstall
linux-image-5.0.0-32-generic deinstall
2) 現在使用されているカーネルのバージョンを確認します。
$ uname -r
5.4.0-146-generic
3) 現在使用されていないカーネルを削除します。
$ sudo apt-get remove linux-image-***-generic
3. Nvidia使用時に使用できるコマンド
1) グラフィックスカードの基本情報を確認する
$ nvidia-smi
Tue Sep 5 23:43:55 2023
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 470.182.03 Driver Version: 470.182.03 CUDA Version: 11.4 |
|-------------------------------+----------------------+----------------------+
| 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 TITAN X ... Off | 00000000:02:00.0 Off | N/A |
| 26% 46C P8 11W / 250W | 0MiB / 12196MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 1 NVIDIA TITAN X ... Off | 00000000:03:00.0 Off | N/A |
| 30% 52C P8 12W / 250W | 0MiB / 12196MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 2 NVIDIA TITAN X ... Off | 00000000:82:00.0 Off | N/A |
| 34% 58C P8 15W / 250W | 0MiB / 12196MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
| 3 NVIDIA TITAN X ... Off | 00000000:83:00.0 Off | N/A |
| 32% 55C P8 13W / 250W | 0MiB / 12196MiB | 0% Default |
| | | N/A |
+-------------------------------+----------------------+----------------------+
+-----------------------------------------------------------------------------+
| Processes: |
| GPU GI CI PID Type Process name GPU Memory |
| ID ID Usage |
|=============================================================================|
| No running processes found |
+-----------------------------------------------------------------------------+
2) Nvidia ドライバーと CUDA ランタイム バージョンの対応関係は
、Nvidia 公式 Web サイトのアドレスで確認できますhttps://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
。最新のドライバーと CUDAランタイムバージョンの対応は次のとおりです:
3) conda を使用して TensorFlow をインストールします。Conda を
使用して Tensorflow-GPU をインストールすると、最も重要な CUDA や cuDNN などの依存関係が自動的にダウンロードされます。
パッケージ:
$ conda search tensorflow
TensorFlow-GPU 2.4.1 をインストールする
$ conda install tensorflow-gpu=2.4.1
4) pip を使用して TensorFlow をインストールし
、cudatookit をインストールします。
$ pip install cudatoolkit==11.8.0
cudnn をインストールします。
$ pip install cudnn
TensorFlow-GPU 2.4.1 をインストールします。
$ pip install tensorflow-gpu==2.4.1
具体的なバージョンは実際の状況に応じて調整されます。!!
4. Jupyter Notebook のいくつかの構成
Jupyter Notebook の一部の構成により、コード開発作業が容易になります。
1) 設定ファイルの生成
$ jupyter notebook --generate-config
ファイルは現在のユーザー ディレクトリに生成されます: .jupyter/jupyter_notebook_config.py
2) 現在のユーザーのログイン パスワードを生成します。
ipython を開いて暗号文のパスワードを作成します。
$ ipython
Python 3.8.16 (default, Mar 2 2023, 03:21:46)
Type 'copyright', 'credits' or 'license' for more information
IPython 8.12.2 -- An enhanced Interactive Python. Type '?' for help.
In [1]:from notebook.auth import passwd
In [2]:passwd()
Enter password:
Verify password:
3) 設定ファイルを変更する
設定ファイルを次のように変更します。
$ vim ~/.jupyter/jupyter_notebook_config.py
c.NotebookApp.ip = '*' # 设置所有ip皆可访问
c.NotebookApp.password = u'argon2:$argon....' # 粘贴上一步生成的密文
c.NotebookApp.open_browser = False # 禁止自动打开浏览器
c.NotebookApp.port = 8899 # 指定端口
4) jupyter ノートブックを起動します。
ログを記録せずにバックグラウンドで起動するのが最善です。
$ nohup jupyter notebook >/dev/null 2>&1 &
次に、ブラウザに http://YOUIP:port と入力して、jupyter ノートブック インターフェイスに入ることができます。
5. TensorFlow の一般的な操作
1) TensorFlow のインストールが成功したかどうかを確認します。
$ python
Python 3.8.16 (default, Mar 2 2023, 03:21:46)
[GCC 11.2.0] :: Anaconda, Inc. on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2023-09-06 00:18:25.800736: I tensorflow/core/platform/cpu_feature_guard.cc:182] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: AVX2 FMA, in other operations, rebuild TensorFlow with the appropriate compiler flags.
2023-09-06 00:18:28.733394: W tensorflow/compiler/tf2tensorrt/utils/py_utils.cc:38] TF-TRT Warning: Could not find TensorRT
>>> print(tf.__version__)
2.12.0
>>> print(tf.test.is_gpu_available())
WARNING:tensorflow:From <stdin>:1: is_gpu_available (from tensorflow.python.framework.test_util) is deprecated and will be removed in a future version.
Instructions for updating:
Use `tf.config.list_physical_devices('GPU')` instead.
2023-09-06 00:19:04.284931: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1956] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
False
>>> print(tf.config.list_physical_devices('GPU'))
2023-09-06 00:19:26.509357: W tensorflow/core/common_runtime/gpu/gpu_device.cc:1956] Cannot dlopen some GPU libraries. Please make sure the missing libraries mentioned above are installed properly if you would like to use GPU. Follow the guide at https://www.tensorflow.org/install/gpu for how to download and setup the required libraries for your platform.
Skipping registering GPU devices...
[]
通常の実行が成功した場合は、現在利用可能な GPU 番号が返されます。どうやらここに問題があり、いくつかのライブラリが欠落しています。
注: TensorFlow をインストールするには conda を使用することをお勧めします。
6. PyTorch を使用した一部の操作
1) PyTorch 公式 Web サイトにログインし、インストール構成を選択します。
最新バージョンを選択することも、以下のリンクに従って古いバージョンを選択することもできます。
2) CUDA を使用してインストールする
ここでは、CUDA バージョンに基づいて v1.13.0 PyTorch GPU バージョンをインストールすることを選択します。
# CUDA 11.6
conda install pytorch==1.13.0 torchvision==0.14.0 torchaudio==0.13.0 pytorch-cuda=11.6 -c pytorch -c nvidia
国内ミラーよりも優先度の高いPyTorchをダウンロードするチャネルをパラメータで指定している-c pytorch
ため、実行できない場合やダウンロードが非常に遅い場合は削除しても問題ありません。3) pip を使用してインストールする-c
# CUDA 11.6
pip install torch==1.13.0+cu116 torchvision==0.14.0+cu116 torchaudio==0.13.0 --extra-index-url https://download.pytorch.org/whl/cu116
5) インストールが成功したかどうかを確認します
>>> import torch
>>> print(torch.__version__)
2.0.1+cu117
>>> print(torch.cuda.is_available())
True
7. インストール元を国内の住所に変更します
1) conda インストール ソースを Tsinghua ソースに変更し
、ユーザーの現在のディレクトリにファイルを作成し.condarc
、そのファイルに次の内容を追加します。
channels:
- defaults
show_channel_urls: true
default_channels:
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
deepmodeling: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/
2) pip インストール ソースを変更し
、ここで清華ソースを選択します。
一時的な使用:pip install -i https://pypi.tuna.tsinghua.edu.cn/simple some-package
デフォルトとして設定:
python -m pip install --upgrade pip
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple