-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup-cuda2.sh
More file actions
53 lines (42 loc) · 1.73 KB
/
setup-cuda2.sh
File metadata and controls
53 lines (42 loc) · 1.73 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
#!/bin/bash
# Append CUDA path to .bashrc
echo 'export PATH=/usr/local/cuda-12.3/bin${PATH:+:${PATH}}' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=/usr/local/cuda-12.3/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}' >> ~/.bashrc
# Source the .bashrc to update the environment variables
source ~/.bashrc
# Check the status of the nvidia-persistenced service using the systemctl command
status=$(systemctl is-active nvidia-persistenced)
# If the service is not active, nvidia-persistenced will be started
if [ "$status" == "active" ]; then
echo "NVIDIA Persistence Daemon is active."
else
echo "NVIDIA Persistence Daemon is not active." >&2
echo "Attempting to start NVIDIA Persistence Daemon..." >&2
sudo systemctl start nvidia-persistenced || { echo "Failed to start nvidia-persistenced service." >&2; exit 1; }
fi
# Make cuda samples
cd ~/
git clone https://github.com/NVIDIA/cuda-samples.git
cd cuda-samples
sudo apt-get update
sudo apt-get -y install cmake
make
# Execute the deviceQuery command and store the output in a variable
output=$(./Samples/1_Utilities/deviceQuery/deviceQuery)
# Check if the output contains "Result = PASS" by analyzing the output
if echo "$output" | grep -q "Result = PASS"; then
echo "The deviceQuery result is PASS."
else
echo "Failed to execute deviceQuery." >&2
exit 1
fi
# Execute the bandwidthTest command and store the output in a variable
output=$(./Samples/1_Utilities/bandwidthTest/bandwidthTest)
# Check if the output contains "Result = PASS" by analyzing the output
if echo "$output" | grep -q "Result = PASS"; then
echo "The bandwidthTest result is PASS."
else
echo "Failed to execute bandwidthTest." >&2
exit 1
fi
sudo apt-get -y remove --purge "cuda-repo-ubuntu2004-12-3-local*"