diff --git a/infra/activate_cobalt.sh b/infra/activate_cobalt.sh
index a40432b22b4911fc9a7396610816842306ce2b8f..f55b5aee8614248540ddfca7f79e14160f41f723 100644
--- a/infra/activate_cobalt.sh
+++ b/infra/activate_cobalt.sh
@@ -28,7 +28,7 @@ module load "${MODULES[@]}"
 export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_ROOT/targets/x86_64-linux/lib
 
 # Some of GCCs libraries are not found, add them to the library path
-GCC_VERSION_MAJOR=$(echo $GCC_VERSION | cut -d. -f1)
+GCC_VERSION_MAJOR=$(gcc -dumpversion)
 export LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib/gcc/x86_64-linux-gnu/$GCC_VERSION_MAJOR
 
 # Make OpenMPI config findable