Reputation: 8426
How do you set environment variables in Colab that persist after a runtime restart?
I have tried:
~/.bashrc
!echo "LD_LIBRARY_PATH=/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/opt/ros/melodic/lib" >> /etc/environment
/etc/environment
!echo "source /opt/ros/melodic/setup.bash" >> ~/.bashrc
Questions that don't have the answer:
Setting environment variables in Google Colab : All methods listed here do not persist after runtime restart
Upvotes: 3
Views: 4103
Reputation: 40888
You can make it permanent, even after restart.
Just write a startup file. It will be run everytime jupyter restart. (but not if factory reset)
%%file /root/.ipython/profile_default/startup/startup.py
import os
os.environ['LD_LIBRARY_PATH']='/usr/local/nvidia/lib:/usr/local/nvidia/lib64:/opt/ros/melodic/lib'
Upvotes: 2