Sublime Forum

Running TensorFlow and CUDA in Sublime Text 3

#1

Hi, everyone!
I’m a data science enthusiast, and i’m trying to run tensorflow-gpu and CUDA in ST3.

I have a Python Virtualenv called datascience, which contains Keras and TensorFlow (version 1.5, that works with CUDA 9.0) libraries, running with CUDA 9.0.

When i run the datascience virtualenv in the terminal, it works well, without any error, but when i run the same virtualenv to Build in ST3, to run my scripts and train my networks, i’m getting the following error:

ImportError: libcublas.so.9.0: cannot open shared object file: No such file or directory

Note that tensorflow works well in terminal (within the datascience virtualenv), and return the error above when i run it in ST3.

Someone help me, please!

0 Likes

#2

You haven’t posted any details of your ST build config, so it’s hard to tell, but it’s most likely that your environment isn’t configured correctly when you run under the build command. Have a look at what environment vars are missing compared to when you run in the terminal.

See the ‘env’ build config option: https://www.sublimetext.com/docs/3/build_systems.html

0 Likes

#3

The key to understand why it’s not working is actually quite simple… a child process inherits its initial environment from its parent so unless you didn’t start Sublime from the console where your virtualenv was active don’t expect the environment of Sublime process to be the same, therefore you’ll get those import errors.

Make a litte experiment, start sublime from the process where your virtualenv is enabled and working ok, then just run the python in sublime and everything should work (unless you’re doing something funny)

Obviously, you don’t want to be forced to run Sublime from any specific parent process so yeah, using a proper build system that setup your environment similarly to your virtualenv as @nutjob2 pointed out in his answer is the right way to go here.

1 Like

#4

Hi!
I changed to Miniconda, just to test and see if the problem persists as when i use Virtualenv. Nothing changed, the problem is the same. I’m pasting below some configurations from ST3 files.

SublimeREPL:
I’m using REPL to run the python interpreter in the interactive mode, but i pointed the interpreter to the one i’ve installed inside my datascience Miniconda environment.

The Python interpreter pointed into the SublimeREPL config/Python/Main.sublime-menu file:
/home/gonsalesarthur/miniconda3/envs/datascience/bin/python

Conda (ST3 Package):
I’m using this package to manage my environments inside Sublime Text, so here i’m showing the User Package Control Settings:

// Default settings for sublime-text-conda:
{
** // executable is the path to anaconda’s python**
** // this python executable is used in order to find conda**
** “executable”: “~/miniconda3/bin/python3”,**

** // Directory in which the conda envs are stored**
** // Default location is the user’s home directory**
** “environment_directory”: “~/miniconda3/envs/”,**

** // configuration is the path to conda’s configuration file**
** “configuration”: “~/.condarc”**
}

I think it’s more clear now :slight_smile:

0 Likes

#5

Hi, @BPL,
I don’t know if the answer that i just give above change anything based on your comment. :slight_smile:

0 Likes

#6

Omg, thank you so much, i’ve just spent half of a day searching and finally saw your comment! The answer was so close and so simple! Thanks again! :partying_face:

0 Likes