-
Notifications
You must be signed in to change notification settings - Fork 0
/
get-gencode
executable file
·35 lines (29 loc) · 976 Bytes
/
get-gencode
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
#!/bin/bash
set -e
# Set the temp directory
temp_dir=$(mktemp -d -t cudaComputeVersion-XXXXXX)
# create a 'here document' that is code we compile and use to probe the card
cat << EOF > "$temp_dir/cudaComputeVersion.cu"
#include <stdio.h>
int main()
{
cudaDeviceProp prop;
cudaGetDeviceProperties(&prop,0);
int v = prop.major * 10 + prop.minor;
printf("Device Name:\n%s\n\n", prop.name);
printf("Your device architecture: \n-gencode arch=compute_%d,code=sm_%d\n",v,v);
}
EOF
# Cleanup function to remove temp files
cleanup() {
rm -rf "$temp_dir"
}
# Trap any kind of termination and cleanup
trap cleanup EXIT
# probe the card and cleanup
$CUDA_PATH/bin/nvcc "$temp_dir/cudaComputeVersion.cu" -o "$temp_dir/cudaComputeVersion"
"$temp_dir/cudaComputeVersion"
if command -v bladebit_cuda >/dev/null && command -v cuobjdump >/dev/null; then
echo -ne "\\nYour bladebit_cuda was built with:"
cuobjdump $(which bladebit_cuda) | grep -v 'Fatbin'
fi