0

I am on an AWS GPU instance and am using rc.local to start Jupyter Notebook:

/etc/rc.local contains:

export PATH=/usr/local/cuda-7.5/bin:$PATH                                                                                          
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64                                                                                                                                                            
sudo su ubuntu -c 'bash /home/ubuntu/OnStartJupyter.sh'                                                                            
exit 0

So when my aws instance turns on the commands above should execute.

/home/ubuntu/OnStartJupyter.sh contains:

#!/bin/bash                                                                                                                        
export PATH=/usr/local/cuda-7.5/bin:$PATH                                                                                          
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64                                                                                   
nohup sudo ipython notebook --profile=nbserver &

However, when I open up a jupyter notebook and look at my environment variables:

import os
os.environ

I do not see the exports I have done. I only see:

{'LANG': 'en_US.UTF-8', 'USERNAME': 'root', 'TERM': 'xterm-color', 'SHELL': '/bin/bash', 'JPY_PARENT_PID': '1383', 'SUDO_COMMAND': '/usr/local/bin/ipython notebook --profile=nbserver', 'PAGER': 'cat', 'SUDO_UID': '1000', 'SUDO_GID': '1000', 'CLICOLOR': '1', 'LOGNAME': 'root', 'USER': 'root', 'MAIL': '/var/mail/root', 'PATH': '/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin', 'SUDO_USER': 'ubuntu', 'HOME': '/home/ubuntu', 'GIT_PAGER': 'cat'}

What can be done to export variables so that Jupyter Notebook started from within rc.local has access to those exported variables?

(This is important because I have a python library, tensorflow, which requires that I have certain environment variables specifying the location of CUDA)

Thomas K
  • 39,200
  • 7
  • 84
  • 86
killajoule
  • 3,612
  • 7
  • 30
  • 36

0 Answers0