Need to run a script and use nvidia-settings to make CUDA available (from my nvidia GPU). Is there a quicker way?

1

My laptop has two graphics units - Intel HD graphics and a 2015 nvidia GPU. Whenever I want to switch to the GPU, I need to do the following two steps:

Step 1: Run a script

echo Updating alternatives
sudo update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/nvidia-352-prime/ld.so.conf
sudo update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/nvidia-352-prime/alt_ld.so.conf

echo "Starting nvidia-352"
sudo modprobe nvidia-352

Step 2: Use nvidia-settings

# Open nvidia-settings
# Select Nvidia, enter my password (gsudo) and then quit the window.

Is there a way I can incorporate Step 2 into my script in Step 1?

Utkarsh Sinha

Posted 2016-03-11T15:26:46.727

Reputation: 1 327

Answers

0

Opening nvidia-settings essentially run prime-select. Here is what the CLI equivalent looks like:

prime-select nvidia

So now my script looks like this:

echo Updating alternatives
sudo update-alternatives --set x86_64-linux-gnu_gl_conf /usr/lib/nvidia-352-prime/ld.so.conf
sudo update-alternatives --set i386-linux-gnu_gl_conf /usr/lib/nvidia-    352-prime/alt_ld.so.conf

echo "Starting nvidia-352"
sudo modprobe nvidia-352

sudo prime-select nvidia

Utkarsh Sinha

Posted 2016-03-11T15:26:46.727

Reputation: 1 327