公式のホームページの通りにGOをインストールします。
「VERSION=1.21.3」の部分は、「https://github.com/sylabs/singularity/releases/」でインストールするSingularityのバージョンを探して、そのバージョンをコンパイルしているGO言語のバージョンを指定します。
今回は「SingularityCE 4.0.1」をインストールするので、「These packages were built with Go 1.21.3」の記述通りに「Go 1.21.3」を指定します。
export VERSION=4.0.1 && # adjust this as necessary \
wget https://github.com/sylabs/singularity/releases/download/v${VERSION}/singularity-ce-${VERSION}.tar.gz && \
tar -xzf singularity-ce-${VERSION}.tar.gz && \
cd singularity-ce-${VERSION}
./mconfig && \
make -C ./builddir && \
sudo make -C ./builddir install
Singularityのバージョンを確認します。
singularity version
4.0.1
nvidia-container-cliコマンドのパスを確認します。
sudo vi /usr/local/etc/singularity/singularity.conf
nvidia-container-cli path = /usr/bin/nvidia-container-cli
singularity pull docker://nvcr.io/nvidia/tensorflow:23.10-tf2-py3
singularity run --nv ~/singularity/tensorflow_23.10-tf2-py3.sif
pythonのコンソールに入って「import tensorflow as tf」、「tf.config.list_physical_devices(‘GPU’)」で確認します。
以下がその結果で、ホストのGPUを認識しています。
13:4: not a valid test operator: (
13:4: not a valid test operator: 525.125.06
================
== TensorFlow ==
================
NVIDIA Release 23.10-tf2 (build 70926626)
TensorFlow Version 2.13.0
Container image Copyright (c) 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
Copyright 2017-2023 The TensorFlow Authors. All rights reserved.
Various files include modifications (c) NVIDIA CORPORATION & AFFILIATES. All rights reserved.
This container image and its contents are governed by the NVIDIA Deep Learning Container License.
By pulling and using the container, you accept the terms and conditions of this license:
NOTE: CUDA Forward Compatibility mode ENABLED.
Using CUDA 12.2 driver version 535.104.05 with kernel driver version 525.125.06.
See https://docs.nvidia.com/deploy/cuda-compatibility/ for details.
SingularityのコンソールからGPUが認識できているか確認します。
Singularity> python
Python 3.10.12 (main, Jun 11 2023, 05:26:28) [GCC 11.4.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import tensorflow as tf
2023-10-15 14:59:28.701126: I tensorflow/core/util/port.cc:110] oneDNN custom operations are on. You may see slightly different numerical results due to floating-point round-off errors from different computation orders. To turn them off, set the environment variable `TF_ENABLE_ONEDNN_OPTS=0`.
2023-10-15 14:59:29.251742: I tensorflow/core/platform/cpu_feature_guard.cc:183] This TensorFlow binary is optimized to use available CPU instructions in performance-critical operations.
To enable the following instructions: SSE3 SSE4.1 SSE4.2 AVX, in other operations, rebuild TensorFlow with the appropriate compiler flags.
tf.config.list_physical_devices('GPU')
>>> tf.config.list_physical_devices('GPU')
[PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
また、SingularityのコンソールからCUDAのバージョンを確認します。
Singularity> nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2023 NVIDIA Corporation
Built on Tue_Aug_15_22:02:13_PDT_2023
Cuda compilation tools, release 12.2, V12.2.140
Build cuda_12.2.r12.2/compiler.33191640_0
Comments