When launching jupyter notebook instance, pass base docker image to the running jupyter

This commit is contained in:
allegroai 2020-07-30 14:50:24 +03:00
parent e9f950f939
commit 29727b80b7
2 changed files with 13 additions and 3 deletions

View File

@ -8,13 +8,13 @@ from tempfile import mkstemp
import psutil import psutil
# make sure we have jupyter in the auto requirements # make sure we have jupyter in the auto requirements
import jupyter # noqa
from trains import Task from trains import Task
# set default docker image, with network configuration
os.environ["TRAINS_DOCKER_IMAGE"] = "nvidia/cuda --network host"
# initialize TRAINS # initialize TRAINS
task = Task.init(project_name="examples", task_name="Remote Jupyter NoteBook", task_type=Task.TaskTypes.service) task = Task.init(
project_name="DevOps", task_name="Allocate Jupyter Notebook Instance", task_type=Task.TaskTypes.service)
# get rid of all the runtime TRAINS # get rid of all the runtime TRAINS
preserve = ( preserve = (
@ -25,6 +25,7 @@ preserve = (
"TRAINS_API_ACCESS_KEY", "TRAINS_API_ACCESS_KEY",
"TRAINS_API_SECRET_KEY", "TRAINS_API_SECRET_KEY",
"TRAINS_API_HOST_VERIFY_CERT", "TRAINS_API_HOST_VERIFY_CERT",
"TRAINS_DOCKER_IMAGE",
) )
# setup os environment # setup os environment
@ -38,9 +39,15 @@ param = {
"jupyter_server_base_directory": "~/", "jupyter_server_base_directory": "~/",
"ssh_server": True, "ssh_server": True,
"ssh_password": "training", "ssh_password": "training",
"default_docker_for_jupyter": "nvidia/cuda",
} }
task.connect(param) task.connect(param)
# set default docker image, with network configuration
os.environ["TRAINS_DOCKER_IMAGE"] = param['default_docker_for_jupyter']
task.set_base_docker("{} --network host".format(param['default_docker_for_jupyter']))
# noinspection PyBroadException # noinspection PyBroadException
try: try:
hostname = socket.gethostname() hostname = socket.gethostname()

View File

@ -0,0 +1,3 @@
jupyter
psutil
trains