google-deepmind / tapnet

Tracking Any Point (TAP)
https://deepmind-tapir.github.io/blogpost.html
Apache License 2.0
1.27k stars 119 forks source link

Running TAPNET in Windows? #49

Open vitacon opened 1 year ago

vitacon commented 1 year ago

I am trying to run TAPNET in Windows 11 with Anaconda3-2023.07-2-Windows-x86_64.exe but I still get a JAX related error message. I already installed jaxlib-0.4.11-cp311-cp311-win_amd64.whl but it´s apparently not enough.

(base) C:\Users\ATC\tapnet>python ./experiment.py --config ./configs/tapir_config.py
Traceback (most recent call last):
  File "C:\Users\ATC\tapnet\experiment.py", line 29, in <module>
    from jaxline import experiment
  File "C:\ProgramData\anaconda3\Lib\site-packages\jaxline\experiment.py", line 30, in <module>
    from jaxline import utils
  File "C:\ProgramData\anaconda3\Lib\site-packages\jaxline\utils.py", line 335, in <module>
    rng: jnp.DeviceArray,
         ^^^^^^^^^^^^^^^
  File "C:\ProgramData\anaconda3\Lib\site-packages\jax\_src\deprecations.py", line 53, in getattr
    raise AttributeError(f"module {module!r} has no attribute {name!r}")
AttributeError: module 'jax.numpy' has no attribute 'DeviceArray'

conda list includes this:

jax                       0.4.14                   pypi_0    pypi
jaxlib                    0.4.11                   pypi_0    pypi
jaxline                   0.0.5                    pypi_0    pypi

Can somebody tell me what I am doing wrong?

vitacon commented 1 year ago

FYI I made a step forward by running this: pip install "jax[cpu]===0.4.11" -f https://whls.blob.core.windows.net/unstable/index.html --use-deprecated legacy-resolver

It installed a slightly different version. =}

Now I am stuck on missing tensorflow. tensorflow -> python[version='3.10.|3.9.|3.8.|3.7.|3.6.|3.5.'] Your python: python=3.11

I suppose I have to downgrade python.

yangyi02 commented 1 year ago

Hi vitacon,

Unfortunately we don't have experinece running the TAP models in this repository on Window. However, there is another related issue, please take a look if that is helpful https://github.com/deepmind/tapnet/issues/25

vitacon commented 1 year ago

Thanks for the reply.

Unfortunately we don't have experinece running the TAP models in this repository on Window. However, there is another related issue, please take a look if that is helpful #25

I already read that - that's why I started experimenting with jax and it seems this part is solved.

On my other computer with an older installation of conda I got i bit farther but I still can't make it work.

It missed kubric even though it's not listed in requirements so I used pip install kubric

It updated a lot of libraries and I got an error that seemed to be related to tensorflow.

File "C:\Users\Vita\Anaconda3\lib\site-packages\keras\src\saving\legacy\saved_model\load_context.py", line 68, in <module>
    tf.__internal__.register_load_context_function(in_load_context)
AttributeError: module 'tensorflow.compat.v2.__internal__' has no attribute 'register_load_context_function'

This led me to a Tensorflow forum suggesting removing keras.

pip uninstall keras
pip install tensorflow

I did that and I now I get a different error. =}

File "C:\Users\Vita\Anaconda3\lib\site-packages\etils\enp\numpy_utils.py", line 150, in is_tf_dtype
    return self.has_tf and isinstance(dtype, self.tf.dtypes.DType)
AttributeError: module 'tensorflow' has no attribute 'dtypes'
yangyi02 commented 1 year ago

pip install kubric is not recommended.

Instead, try download kubric from github as a subdirectory and place it as a separate directory beside tapnet.

git clone https://github.com/google-research/kubric.git

Install requirements:

pip install -r requirements.txt
vitacon commented 1 year ago

By "beside" you mean parallel with tapnet?

Directory of C:\Users\Vita\video

23.08.2023  20:56    <DIR>          .
23.08.2023  20:56    <DIR>          ..
23.08.2023  20:58    <DIR>          kubric
22.08.2023  18:49    <DIR>          tapnet

It does not seem to change anything and I still get the same error related to tensorflow. I think I should focus on that.

weirenorweiren commented 10 months ago

Hi @vitacon, I am curious that have you managed to run the code on Windows? I followed the instruction on the front page and managed to pip install -r requirements.txt (not the requirements_inference.txt) in an Anaconda environment. However, I encountered the following problem:

(tapnet) Z:\Wei>python3 ./tapnet/live_demo.py
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

I guess it results from the fact that I don't know the Windows equivalent for export PYTHONPATH=(cd ../ && pwd):pwd:$PYTHONPATH. If you happen to have some experience on this issue, I appreciate it if you could share!

weirenorweiren commented 10 months ago

I also tried to change python3 into python. The previous issue is gone but replaced with the followings. Before that, I also randomly tried setx.exe PYTHONPATH and set PYTHONPATH according to some web search but nothing changed. I am not sure whether setx.exe PYTHONPATH and set PYTHONPATH caused the following errors... Any advices or comments would be appreciated!

(tapnet) Z:\Wei>python ./tapnet/live_demo.py
Traceback (most recent call last):
  File "Z:\Wei\tapnet\live_demo.py", line 26, in <module>
    from tapnet import tapir_model
ModuleNotFoundError: No module named 'tapnet'
(tapnet) Z:\Wei\tapnet>python ./live_demo.py
Traceback (most recent call last):
  File "Z:\Wei\tapnet\live_demo.py", line 26, in <module>
    from tapnet import tapir_model
ModuleNotFoundError: No module named 'tapnet'
vitacon commented 10 months ago

have you managed to run the code on Windows?

Hello, no - unfortunately I got stuck on the tensorflow problem and I let it be.

guess it results from the fact that I don't know the Windows equivalent for export PYTHONPATH=

I used this: set PYTHONPATH=\users\vita\video\tapnet I.e. I just set the value of the environment variable PYTHONPATH to the path of the TAPNET project on my disk.

weirenorweiren commented 10 months ago

Thanks for the reply! I tried everything I could think of, however, it still doesn't work...

(tapnet) Z:\Wei\tapnet>set PYTHONPATH=Z:\Wei\tapnet

(tapnet) Z:\Wei\tapnet>python ./live_demo.py
Traceback (most recent call last):
  File "Z:\Wei\tapnet\live_demo.py", line 26, in <module>
    from tapnet import tapir_model
ModuleNotFoundError: No module named 'tapnet'

(tapnet) Z:\Wei\tapnet>cd ..

(tapnet) Z:\Wei>python ./tapnet/live_demo.py
Traceback (most recent call last):
  File "Z:\Wei\tapnet\live_demo.py", line 26, in <module>
    from tapnet import tapir_model
ModuleNotFoundError: No module named 'tapnet'

(tapnet) Z:\Wei>set PYTHONPATH=Z:\Wei\tapnet

(tapnet) Z:\Wei>python ./tapnet/live_demo.py
Traceback (most recent call last):
  File "Z:\Wei\tapnet\live_demo.py", line 26, in <module>
    from tapnet import tapir_model
ModuleNotFoundError: No module named 'tapnet'

(tapnet) Z:\Wei>python3 ./tapnet/live_demo.py
Python was not found; run without arguments to install from the Microsoft Store, or disable this shortcut from Settings > Manage App Execution Aliases.

I would do more study on those commands and thanks again for your help!

vitacon commented 9 months ago

from tapnet import tapir_model

I suppose the failing line should just import file tapir_model.py from tapnet folder.

weirenorweiren commented 9 months ago

Thanks for the reply! I finally figured it out with the help of ChatGPT. The Windows equivalence for export PYTHONPATH=(cd ../ && pwd):pwd:$PYTHONPATH is set PYTHONPATH=%cd%\..\;%cd%;%PYTHONPATH%.

vitacon commented 9 months ago

Hm, the variable PYTHONPATH is not defined at the beginning so it basically sets something like this: set PYTHONPATH=Z:\Wei\;Z:\Wei\tapnet\

cdoersch commented 2 weeks ago

FYI, @weirenorweiren reports that the new pip-based installation has gotten it working for them in #71 . Hopefully this is a solution.