Set maximums.
sudo nvpmodel -m 0
sudo jetson_clocks
Monitoring
# Run in another terminal to watch temperature
watch -n 1 'cat /sys/devices/system/cpu/online; echo; grep . /sys/class/thermal/thermal_zone*/temp'
# Or install jtop
sudo -v
curl -LsSf https://raw.githubusercontent.com/rbonghi/jetson_stats/master/scripts/install_jtop_torun_without_sudo.sh | bash
# Or upgrade jtop
sudo -v
curl -LsSf https://raw.githubusercontent.com/rbonghi/jetson_stats/master/scripts/upgrade-jtop.sh | bash
CPU / memory stress
sudo apt install stress-ng
#Control-C kills stress-ng
cat <<'EOF' > stress_ng.sh
#!/usr/bin/env bash
set -euo pipefail
cleanup() {
echo
echo "Stopping stress-ng..."
sudo pkill -TERM stress-ng || true
sleep 2
sudo pkill -KILL stress-ng || true
}
trap cleanup INT TERM EXIT
stress-ng \
--cpu 14 \
--cpu-method matrixprod \
--vm 4 \
--vm-bytes 80% \
--matrix 4 \
--matrix-size 4096 \
--timeout 0 &
STRESS_PID=$!
wait "$STRESS_PID"
EOF
chmod +x stress_ng.sh
GPU stress: CUDA matrix multiply
cat > thor_cuda_stress.cu <<'EOF'
#include <cuda_runtime.h>
#include <cublas_v2.h>
#include <stdio.h>
#include <stdlib.h>
#define CHECK_CUDA(x) do { \
cudaError_t err = (x); \
if (err != cudaSuccess) { \
fprintf(stderr, "CUDA error %s:%d: %s\n", __FILE__, __LINE__, cudaGetErrorString(err)); \
exit(1); \
} \
} while (0)
#define CHECK_CUBLAS(x) do { \
cublasStatus_t err = (x); \
if (err != CUBLAS_STATUS_SUCCESS) { \
fprintf(stderr, "cuBLAS error %s:%d: %d\n", __FILE__, __LINE__, err); \
exit(1); \
} \
} while (0)
int main(int argc, char **argv) {
int n = 8192;
if (argc > 1) n = atoi(argv[1]);
size_t bytes = (size_t)n * n * sizeof(float);
printf("Allocating three %.2f GiB matrices, n=%d\n",
(3.0 * bytes) / (1024.0 * 1024.0 * 1024.0), n);
float *A, *B, *C;
CHECK_CUDA(cudaMalloc(&A, bytes));
CHECK_CUDA(cudaMalloc(&B, bytes));
CHECK_CUDA(cudaMalloc(&C, bytes));
CHECK_CUDA(cudaMemset(A, 1, bytes));
CHECK_CUDA(cudaMemset(B, 2, bytes));
CHECK_CUDA(cudaMemset(C, 0, bytes));
cublasHandle_t h;
CHECK_CUBLAS(cublasCreate(&h));
const float alpha = 1.0f;
const float beta = 0.0f;
unsigned long long iter = 0;
while (1) {
CHECK_CUBLAS(cublasSgemm(
h,
CUBLAS_OP_N,
CUBLAS_OP_N,
n, n, n,
&alpha,
A, n,
B, n,
&beta,
C, n));
CHECK_CUDA(cudaDeviceSynchronize());
if ((++iter % 10) == 0) {
printf("completed %llu GEMMs\n", iter);
fflush(stdout);
}
}
return 0;
}
EOF
# Compile
nvcc -O3 thor_cuda_stress.cu -lcublas -o thor_cuda_stress
# Run
./thor_cuda_stress 8192
# Or
./thor_cuda_stress 12288