-
Notifications
You must be signed in to change notification settings - Fork 0
/
environment.sh
34 lines (33 loc) · 1.47 KB
/
environment.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
containers_running=$(docker ps | grep tensor)
if [ -z "$containers_running" ]
then
container_search=$(
docker ps -a | grep tensor | head -1
)
if [ -z "$container_search" ]
then
container_id=$(
docker run --gpus all -it -v $(pwd):/tf/notebooks -p 8888:8888 -d tensorflow/tensorflow:latest-gpu-jupyter
# docker run --gpus all -it -v $(pwd):/tf/notebooks -p 8888:8888 -d tensorflow/tensorflow:nightly-gpu-jupyter
)
docker exec -it $container_id pip3 install -r notebooks/requirements.txt
logs=$(docker logs $container_id | grep 'http://127.0.0.1:8888/?token=' )
re="^(.*)=(.*)$"
[[ $logs =~ $re ]] && token="${BASH_REMATCH[2]}"
tput setaf 9; echo "LINK PARA ACESSA NOTEBOOKS"
tput setaf 9; echo "http://0.0.0.0:8888/?token=$token"
tput setaf 9; echo "http://127.0.0.1:8888/?token=$token"
else
re="^(.*)tensorflow/tensorflow:nightly-gpu-jupyter(.*)$"
[[ $container_search =~ $re ]] && container_id="${BASH_REMATCH[1]}"
docker start $container_id
logs=$(docker logs $container_id | grep 'http://127.0.0.1:8888/?token=' )
re_log="^(.*)=(.*)$"
[[ $logs =~ $re_log ]] && token="${BASH_REMATCH[2]}"
tput setaf 9; echo "LINK PARA ACESSA NOTEBOOKS"
tput setaf 9; echo "http://0.0.0.0:8888/?token=$token"
tput setaf 9; echo "http://127.0.0.1:8888/?token=$token"
fi
else
echo "Container já está sendo executado!"
fi