Skip to content

Commit c483526

Browse files
authored
Pin TensorFlow according to OS; Fix DeepLabCut install in Colab to deal with new requirements. (#2862)
1 parent b8653f1 commit c483526

8 files changed

Lines changed: 262 additions & 59 deletions

examples/COLAB/COLAB_3miceDemo.ipynb

Lines changed: 45 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@
3232
"- a quick guide to maDLC: https://deeplabcut.github.io/DeepLabCut/docs/tutorial.html\n",
3333
"- a demo COLAB for how to use maDLC on your own data: https://github.com/DeepLabCut/DeepLabCut/blob/main/examples/COLAB/COLAB_maDLC_TrainNetwork_VideoAnalysis.ipynb\n",
3434
"\n",
35-
"### To get started, please go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n"
35+
"### To get started, please go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n",
36+
"\n",
37+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU."
3638
]
3739
},
3840
{
@@ -43,11 +45,49 @@
4345
},
4446
"outputs": [],
4547
"source": [
46-
"# Installs a CUDA version compatible with tensorflow on COLAB\n",
47-
"!apt update && apt install cuda-11-8\n",
48+
"# Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
49+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
50+
]
51+
},
52+
{
53+
"cell_type": "code",
54+
"execution_count": null,
55+
"metadata": {},
56+
"outputs": [],
57+
"source": [
58+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
59+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
60+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"metadata": {},
67+
"outputs": [],
68+
"source": [
69+
"# Install the latest version of DeepLabCut\n",
70+
"!pip install \"git+https://github.com/DeepLabCut/DeepLabCut.git\""
71+
]
72+
},
73+
{
74+
"cell_type": "code",
75+
"execution_count": null,
76+
"metadata": {},
77+
"outputs": [],
78+
"source": [
79+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
80+
"# create symbolic links to NVIDIA shared libraries:\n",
81+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
82+
]
83+
},
84+
{
85+
"cell_type": "markdown",
86+
"metadata": {},
87+
"source": [
88+
"### Important - Restart the Runtime for the updated packages to be imported!\n",
4889
"\n",
49-
"# Install the latest DeepLabCut version:\n",
50-
"!pip install \"deeplabcut[tf]\""
90+
"PLEASE, click \"restart runtime\" from the output above before proceeding!"
5191
]
5292
},
5393
{

examples/COLAB/COLAB_DEMO_SuperAnimal.ipynb

Lines changed: 38 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -43,19 +43,51 @@
4343
"\n",
4444
"## **Let's get going: install DeepLabCut into COLAB:**\n",
4545
"\n",
46-
"*Also, be sure you are connected to a GPU: go to menu, click Runtime > Change Runtime Type > select \"GPU\"*\n"
46+
"*Also, be sure you are connected to a GPU: go to menu, click Runtime > Change Runtime Type > select \"GPU\"*\n",
47+
"\n",
48+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU.\n"
4749
]
4850
},
4951
{
5052
"cell_type": "code",
5153
"execution_count": null,
52-
"metadata": {
53-
"id": "03ylSyQ4O9Ee"
54-
},
54+
"metadata": {},
55+
"outputs": [],
56+
"source": [
57+
"# Cell 1 - Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
58+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
59+
]
60+
},
61+
{
62+
"cell_type": "code",
63+
"execution_count": null,
64+
"metadata": {},
65+
"outputs": [],
66+
"source": [
67+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
68+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
69+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
70+
]
71+
},
72+
{
73+
"cell_type": "code",
74+
"execution_count": null,
75+
"metadata": {},
76+
"outputs": [],
77+
"source": [
78+
"# Install the latest version of DeepLabCut\n",
79+
"!pip install \"git+https://github.com/DeepLabCut/DeepLabCut.git#egg=deeplabcut[modelzoo]\""
80+
]
81+
},
82+
{
83+
"cell_type": "code",
84+
"execution_count": null,
85+
"metadata": {},
5586
"outputs": [],
5687
"source": [
57-
"!apt update && apt install cuda-11-8\n",
58-
"!pip install deeplabcut[tf,modelzoo]"
88+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
89+
"# create symbolic links to NVIDIA shared libraries:\n",
90+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
5991
]
6092
},
6193
{

examples/COLAB/COLAB_DEMO_mouse_openfield.ipynb

Lines changed: 28 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,30 @@
4242
"id": "txoddlM8hLKm"
4343
},
4444
"source": [
45-
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\""
45+
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n",
46+
"\n",
47+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU."
48+
]
49+
},
50+
{
51+
"cell_type": "code",
52+
"execution_count": null,
53+
"metadata": {},
54+
"outputs": [],
55+
"source": [
56+
"# Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
57+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
58+
]
59+
},
60+
{
61+
"cell_type": "code",
62+
"execution_count": null,
63+
"metadata": {},
64+
"outputs": [],
65+
"source": [
66+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
67+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
68+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
4669
]
4770
},
4871
{
@@ -51,8 +74,9 @@
5174
"metadata": {},
5275
"outputs": [],
5376
"source": [
54-
"# Installs a CUDA version compatible with tensorflow on COLAB\n",
55-
"!apt update && apt install cuda-11-8"
77+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
78+
"# create symbolic links to NVIDIA shared libraries:\n",
79+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
5680
]
5781
},
5882
{
@@ -91,7 +115,7 @@
91115
"source": [
92116
"# Install the latest DeepLabCut version (this will take a few minutes to install all the dependencies!)\n",
93117
"%cd /content/cloned-DLC-repo/\n",
94-
"!pip install \".[tf]\""
118+
"!pip install \".\""
95119
]
96120
},
97121
{

examples/COLAB/COLAB_DLC_ModelZoo.ipynb

Lines changed: 42 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -45,29 +45,60 @@
4545
"\n",
4646
"## **Let's get going: install DeepLabCut into COLAB:**\n",
4747
"\n",
48-
"*Also, be sure you are connected to a GPU: go to menu, click Runtime > Change Runtime Type > select \"GPU\"*"
48+
"*Also, be sure you are connected to a GPU: go to menu, click Runtime > Change Runtime Type > select \"GPU\"*\n",
49+
"\n",
50+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU."
4951
]
5052
},
5153
{
5254
"cell_type": "code",
5355
"execution_count": null,
54-
"metadata": {
55-
"id": "q23BzhA6CXxu"
56-
},
56+
"metadata": {},
57+
"outputs": [],
58+
"source": [
59+
"# Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
60+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
61+
]
62+
},
63+
{
64+
"cell_type": "code",
65+
"execution_count": null,
66+
"metadata": {},
5767
"outputs": [],
5868
"source": [
59-
"#click the play icon (this will take a few minutes to install all the dependencies!)\n",
60-
"!apt update && apt install cuda-11-8\n",
61-
"!pip install deeplabcut[tf,modelzoo]"
69+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
70+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
71+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
72+
]
73+
},
74+
{
75+
"cell_type": "code",
76+
"execution_count": null,
77+
"metadata": {},
78+
"outputs": [],
79+
"source": [
80+
"# Install the latest version of DeepLabCut\n",
81+
"!pip install \"git+https://github.com/DeepLabCut/DeepLabCut.git#egg=deeplabcut[modelzoo]\""
82+
]
83+
},
84+
{
85+
"cell_type": "code",
86+
"execution_count": null,
87+
"metadata": {},
88+
"outputs": [],
89+
"source": [
90+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
91+
"# create symbolic links to NVIDIA shared libraries:\n",
92+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
6293
]
6394
},
6495
{
6596
"cell_type": "markdown",
66-
"metadata": {
67-
"id": "zYm6DljQB0Y7"
68-
},
97+
"metadata": {},
6998
"source": [
70-
"###proTip: be sure to click \"restart runtime button\" if it appears above ^"
99+
"### Important - Restart the Runtime for the updated packages to be imported!\n",
100+
"\n",
101+
"PLEASE, click \"restart runtime\" from the output above before proceeding!"
71102
]
72103
},
73104
{

examples/COLAB/COLAB_YOURDATA_TrainNetwork_VideoAnalysis.ipynb

Lines changed: 38 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -48,22 +48,51 @@
4848
"id": "txoddlM8hLKm"
4949
},
5050
"source": [
51-
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n"
51+
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n",
52+
"\n",
53+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU."
5254
]
5355
},
5456
{
5557
"cell_type": "code",
5658
"execution_count": null,
57-
"metadata": {
58-
"colab": {},
59-
"colab_type": "code",
60-
"id": "q23BzhA6CXxu"
61-
},
59+
"metadata": {},
60+
"outputs": [],
61+
"source": [
62+
"# Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
63+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
64+
]
65+
},
66+
{
67+
"cell_type": "code",
68+
"execution_count": null,
69+
"metadata": {},
70+
"outputs": [],
71+
"source": [
72+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
73+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
74+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
75+
]
76+
},
77+
{
78+
"cell_type": "code",
79+
"execution_count": null,
80+
"metadata": {},
81+
"outputs": [],
82+
"source": [
83+
"# Install the latest version of DeepLabCut\n",
84+
"!pip install \"git+https://github.com/DeepLabCut/DeepLabCut.git\""
85+
]
86+
},
87+
{
88+
"cell_type": "code",
89+
"execution_count": null,
90+
"metadata": {},
6291
"outputs": [],
6392
"source": [
64-
"#(this will take a few minutes to install all the dependences!)\n",
65-
"!apt update && apt install cuda-11-8\n",
66-
"!pip install \"deeplabcut[tf]\""
93+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
94+
"# create symbolic links to NVIDIA shared libraries:\n",
95+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
6796
]
6897
},
6998
{

examples/COLAB/COLAB_maDLC_TrainNetwork_VideoAnalysis.ipynb

Lines changed: 31 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -46,36 +46,51 @@
4646
"id": "txoddlM8hLKm"
4747
},
4848
"source": [
49-
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n"
49+
"## First, go to \"Runtime\" ->\"change runtime type\"->select \"Python3\", and then select \"GPU\"\n",
50+
"\n",
51+
"As the COLAB environments were updated to CUDA 12.X and Python 3.11, we need to install DeepLabCut and TensorFlow in a distinct way to get TensorFlow to connect to the GPU."
5052
]
5153
},
5254
{
5355
"cell_type": "code",
5456
"execution_count": null,
55-
"metadata": {
56-
"id": "q23BzhA6CXxu"
57-
},
57+
"metadata": {},
5858
"outputs": [],
5959
"source": [
60-
"#(this will take a few minutes to install all the dependences!)\n",
61-
"!apt update && apt install cuda-11-8\n",
62-
"!pip install \"deeplabcut[tf]\"\n",
63-
"%reload_ext numpy\n",
64-
"%reload_ext scipy\n",
65-
"%reload_ext matplotlib\n",
66-
"%reload_ext mpl_toolkits"
60+
"# Install TensorFlow, tensorpack and tf_slim versions compatible with DeepLabCut\n",
61+
"!pip install \"tensorflow==2.12.1\" \"tensorpack>=0.11\" \"tf_slim>=1.1.0\""
6762
]
6863
},
6964
{
7065
"cell_type": "code",
7166
"execution_count": null,
72-
"metadata": {
73-
"id": "-MVvZ13_FMvP"
74-
},
67+
"metadata": {},
68+
"outputs": [],
69+
"source": [
70+
"# Downgrade PyTorch to a version using CUDA 11.8 and cudnn 8\n",
71+
"# This will also install the required CUDA libraries, for both PyTorch and TensorFlow\n",
72+
"!pip install torch==2.3.1 torchvision --index-url https://download.pytorch.org/whl/cu118"
73+
]
74+
},
75+
{
76+
"cell_type": "code",
77+
"execution_count": null,
78+
"metadata": {},
79+
"outputs": [],
80+
"source": [
81+
"# Install the latest version of DeepLabCut\n",
82+
"!pip install \"git+https://github.com/DeepLabCut/DeepLabCut.git\""
83+
]
84+
},
85+
{
86+
"cell_type": "code",
87+
"execution_count": null,
88+
"metadata": {},
7589
"outputs": [],
7690
"source": [
77-
"#a few colab specific things needed:\n",
78-
"!pip install --upgrade scikit-image"
91+
"# As described in https://www.tensorflow.org/install/pip#step-by-step_instructions, \n",
92+
"# create symbolic links to NVIDIA shared libraries:\n",
93+
"!ln -svf /usr/local/lib/python3.11/dist-packages/nvidia/*/lib/*.so* /usr/local/lib/python3.11/dist-packages/tensorflow"
7994
]
8095
},
8196
{

0 commit comments

Comments
 (0)