-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathchimera_tensorflow.txt
More file actions
84 lines (61 loc) · 2.01 KB
/
Copy pathchimera_tensorflow.txt
File metadata and controls
84 lines (61 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
###
### BOTH ENVS BELOW VERIFIED 3/12 on CHIMERA13
###
#
# Tensorflow 2.5
# using CUDA 11
#
conda create --name TF25 python=3.10
conda install cudatoolkit=11.8.0=h6a678d5_0
conda install cudnn=8.9.2.26=cuda11_0
pip install tensorflow==2.5
### TEST
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
###################################################################################
#
# Tensorflow 2.19
# with locally installed CUDA 12.2
#
conda create --name TF219 python=3.10
conda install nvidia/label/cuda-12.2.0::cuda-toolkit -c nvidia/label/cuda-12.2.0
conda install cudnn
pip install tensorflow==2.19
export PATH=$CONDA_PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
export CUDA_HOME=$CONDA_PREFIX
### TEST (warnings are ok!)
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
#### H200 setup
conda create --name H200 python=3.10
conda install nvidia/label/cuda-12.4.0::cuda-toolkit -c nvidia/label/cuda-12.4.0
conda install cudnn
pip install tensorflow==2.19
export PATH=$CONDA_PREFIX/bin:$PATH
export LD_LIBRARY_PATH=$CONDA_PREFIX/lib:$LD_LIBRARY_PATH
export CUDA_HOME=$CONDA_PREFIX
### TEST (warnings are ok!)
python3 -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
# gives [PhysicalDevice(name='/physical_device:GPU:0', device_type='GPU')]
###################################################################################
#
# REAL PERFORMANCE TEST
# this should yield like 25s vs 0.5s performance difference
#
import tensorflow as tf
import time
# Create a large matrix
size = 10000
a = tf.random.normal((size, size))
b = tf.random.normal((size, size))
# Measure time on CPU
with tf.device('/CPU:0'):
start = time.time()
c_cpu = tf.matmul(a, b)
end = time.time()
print(f"CPU Time: {end - start:.3f} seconds")
# Measure time on GPU
with tf.device('/GPU:0'):
start = time.time()
c_gpu = tf.matmul(a, b)
end = time.time()
print(f"GPU Time: {end - start:.3f} seconds")