How to simply use TSNE CUDA on Google Colab – Best Way

Blocked to use the TSNE CUDA library on Google Colab ? You’ ll find here a step by step tutorial to use it !

It took me a long time to find out how to use TSNE CUDA on Colab.

And often it just takes a little line of code that will work like magic.

For TSNE Cuda, you will find the solution in this article !

The dependencies

First of all, let’s install the tsnecuda library:

!pip install tsnecuda

Next, we will need to use conda for this tutorial !

The installation on Google Colab is singular. It has been detailed in this article.

The code itself :

!pip install -q condacolab
import condacolab

Finally we install the dependencies to tsnecuda :

!tar xvjf tsnecuda-2.1.0-cuda101.tar.bz2
!cp -r site-packages/* /usr/local/lib/python3.7/dist-packages/

Thanks to them we avoid the redundant error: ‘ImportError:’.

Finally, a last dependency allows us to use cuda with tsnecuda :

!conda install --offline tsnecuda-2.1.0-cuda101.tar.bz2

And voilà ! We’re now…

… Ready to use TSNE CUDA on Colab !

Just import the tsnecuda library:

import tsnecuda

Then test if it works with this short code :

from tsnecuda import TSNE as TSNE_CUDA

tsne_cuda = TSNE_CUDA(n_components=2, verbose=0)

Didn’t get any error ? Congratulations ! You’re good to create your own TSNE schemas !

By the way, we will describe in a future article a concrete use case for TSNE sentences visualization.

Still having troubles even after this tutorial ? Feel free to share about it in the comments, we regularly update our articles 😉

sources :

Tom Keldenich
Tom Keldenich

Data Engineer & passionate about Artificial Intelligence !

Founder of the website Inside Machine Learning

Leave a Reply

Your email address will not be published.

Beginner, expert or just curious?Discover our latest news and articles on Machine Learning

Explore Machine Learning, browse our most recent notebooks and stay up to date with the latest practices and technologies!