Repository navigation
Closed
Description
Is there an existing issue for this?
- I have searched the existing issues
Bug description
Hello,
after installation of DLC in miniconda3 environment I am was able to analyze videos with pre-trained networks.
However it is not possible to re-train or train new networks:
The GPU is only used up to 40% while CPU is fully used and after 2.5 hours I reach 1000 iterations.
Afterwards the application memory is depleted and I have to stop the training.
I tried to search for ways to solve this/optimize the GPU usage, but so far I was unsuccessful.
Additionally, also the GUI doesn't show the start of the training, for all other functions you can read what is going in the left corner of the GUI.
Operating System
operating system Ventura 13.3.1
DeepLabCut version
dlc version 2.3.4
DeepLabCut mode
single animal
Device type
32 core GPU
10 core CPU
Steps To Reproduce
- install miniconda3 (anaconda3 uninstalled)
- Update conda
conda update conda
- follow installation steps in DLC installation guide (git clone; cd DLC; conda env create -f DEEPLABCUT_M1.yaml; conda activate DEEPLABCUT_M1)
- Update tensorflow packages as first try of trouble shooting
pip uninstall tensorflow-macos
pip uninstall tensorflow-metal
python -m pip install tensorflow-macos==2.9
pip install tensorflow-metal==0.5.0
- launch DeepLabCut GUI
- Try training network
Relevant log output
/Users/johanna/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/train.py:227: UserWarning: Switching to Adam, as SGD crashes on Apple Silicon.
warnings.warn("Switching to Adam, as SGD crashes on Apple Silicon.")
2023-05-12 08:01:18.764393: W tensorflow/core/platform/profile_utils/cpu_utils.cc:128] Failed to get CPU frequency: 0 Hz
Before uninstalling tensorflow packages i got this output:
UserWarning: layer.apply is deprecated and will be removed in a future version. Please use layer.__call__ method instead.
warnings.warn('layer.apply is deprecated and ’
/Users/alan/DeepLabCut/deeplabcut/pose_estimation_tensorflow/core/train.py:227: UserWarning: Switching to Adam, as SGD crashes on Apple Silicon.
warnings.warn(“Switching to Adam, as SGD crashes on Apple Silicon.”)
2023-04-25 01:06:46.456243: W tensorflow/c/c_api.cc:300] Operation ‘{name:‘resnet_v1_50/block2/unit_4/bottleneck_v1/conv1/weights/Assign’ id:913 op device:{requested: ‘’, assigned: ‘’} def:{{{node resnet_v1_50/block2/unit_4/bottleneck_v1/conv1/weights/Assign}} = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](resnet_v1_50/block2/unit_4/bottleneck_v1/conv1/weights, resnet_v1_50/block2/unit_4/bottleneck_v1/conv1/weights/Initializer/truncated_normal)}}’ was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don’t modify nodes after running them or create a new session.
2023-04-25 01:06:46.522643: W tensorflow/c/c_api.cc:300] Operation ‘{name:‘pose/locref_pred/block4/biases/Adam_1/Assign’ id:7170 op device:{requested: ‘’, assigned: ‘’} def:{{{node pose/locref_pred/block4/biases/Adam_1/Assign}} = AssignVariableOp[_has_manual_control_dependencies=true, dtype=DT_FLOAT, validate_shape=false](pose/locref_pred/block4/biases/Adam_1, pose/locref_pred/block4/biases/Adam_1/Initializer/zeros)}}’ was changed by setting attribute after it was run by a session. This mutation will have no effect, and will trigger an error in the future. Either don’t modify nodes after running them or create a new session.Anything else?
No response
Code of Conduct
- I agree to follow this project's Code of Conduct
Activity
anthonyylee commentedon May 12, 2023
topon the cluster node, it shows 0 CPU usage on the Python script that is running the training whilst its memory utilization is around 25GB (Unable to start training and low-to-none GPU usage on cluster #2232 ).jlm2303 commentedon May 12, 2023
On my Mac I had no other programs running and still I got a notification from my mac "Your system has run out of application memory" with python (DCL) taking up more than 90 GB of the memory.
I checked on the activity monitor and my CPU is oscillating between 98% and 105% and the GPU is used up to 40%.
I am not sure where I should check the CPU memory itself.
For me it just shows "failed to get CPU frequency" as indicated above but it can still run the network training.
I did get to 1000 iterations at a very low learning rate (0.005):
Afterwards either zsh killed python
and for the scenario above as well as when I had to force quit the application, in both cases I got this error message:
I hope this can help you with some of your questions!
n-poulsen commentedon May 16, 2023
Hi @jlm2303,
I was able to reproduce the issues you are having with memory with
tensorflow-macos==2.9andtensorflow-metal==0.5.0. The answer for me was to use the latest version of those packages (tensorflow-macos==2.12.0andtensorflow-metal==0.8.0), with which I had no issues.When it comes to performance (training and inference speed) of TensorFlow on MacOS dropping, this is a known issue that is not related to DeepLabCut. One of our users documented this well and tried different parameters to maximise speed anyways.
To increase training speed, I would try the following:
pose_cfg.yaml, which can be done in the "Train network" tab of the GUI). This should increase the GPU usage on your machine. Note that the number of iterations represents the number of batches. So if each iteration takes the same amount of time but your batch size goes from 1 to 16, you are actually training 16 times faster.Currently, the only way to get very good performance while training is to use an NVIDIA GPU. So if you need better training performance, using Google Colab (there are some demos for that here) or a machine with a dedicated NVIDIA GPU is the way to go.
jlm2303 commentedon May 16, 2023
Hi @n-poulsen,
many thanks for your help.
I found the mentioned thread about GPU usage and batch size as well, but since my training never finished I figured it must be something else as well.
I also started to train my network on a different GPU and for analysis I can use the Mac without problems.