Skip to content


Using CUDA 9.0 GPUs on a modern Ubuntu install

If you have an older GPU that only supports CUDA 9.0 you can’t simply install the latest tools on a modern Ubuntu, they just won’t work as it requires an older version of many libraries.

To make it work we’re going to isolate everything we need in a conda environment, and use that whenever we need to work with the GPU. Here’s what you have to do:

Install miniconda and then execute this:

conda create -n cuda python=3.6
conda activate cuda
conda install gcc-6 cudatoolkit=9.0 tensorflow-gpu==1.12.0 numpy==1.16.0 -c pytorch -c hcc -c omgarcia

Now you can use your CUDA 9.0 GPU whenever you are in the cuda environment. Here’s how you can enter and exit your cuda environment at any time:

#To exit your cuda environment:
conda deactivate

#To enter your cuda environment:
conda activate cuda

Now let’s test it with python (make sure you are in the cuda environment, otherwise it will say False):

import tensorflow as tf
value = tf.test.is_gpu_available()
print("GPU available?: ", value)

It should tell you:

GPU available?:  True

Now let’s try CUDA with CMake in a simple example. Basically this project creates a function in CUDA that adds two integers, and then the main program uses it to calculate 5 + 3 in the GPU. Amazing stuff. Let’s see if it works:

git clone https://github.com/Yannnnnnnnnnnn/cuda_cmakelists.git
cd cuda_cmakelists
mkdir build
cd build
cmake ..
make
./Demo

You should get the answer, which is 8 by the way. If you see that, it means you can now create a CUDA function, send data to your GPU, and then use that function on a program, all ready to use with CMake.

Posted in Programming.

Tagged with , , , .


Install Jekyll without sudo

When using the default installation of jekyll it will ask for sudo access when creating a new project:

Your user account is not allowed to install to the system RubyGems.
You can cancel this installation and run:

    bundle install --path vendor/bundle

to install the gems into ./vendor/bundle/, or you can enter your password
and install the bundled gems to RubyGems using sudo.

Password:

That’s not good. Here’s how you can install Jekyll without requiring sudo access.

First, make sure that you have installed ruby with this command:

bundle env

By default Gem Home is set to a directory that requires sudo access. You can change it by adding these two lines to ~/.bashrc (or equivalent)

export GEM_HOME=$HOME/gems
export PATH=$HOME/gems/bin:$PATH

Now open a new console, restart, or login again, and run the same command again:

bundle env

If it’s showing the changes you just did, then you’ll be able to install jekyll locally:

gem install bundle jekyll

And now you can proceed to use jekyll as usual:

jekyll new blog

Posted in Programming.

Tagged with , , .