Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

FCN ObjectSegmentation with PyTorch backend #2041

Merged
merged 9 commits into from Apr 12, 2017

Conversation

wkentaro
Copy link
Member

@wkentaro wkentaro commented Mar 26, 2017

For start-jsk/jsk_apc#2042

Why PyTorch?

Its much faster than Chainer.
By using Chainer, we get 1Hz output with VGA image input, but we get 5Hz output by using PyTorch.

For FCN with improvement of Relu implementation, now it is as fast as PyTorch: (See https://github.com/wkentaro/pytorch-fcn#speed)
I am currently mainly using PyTorch for its functionality: functions, layers and multi-gpu training.

Why not rosdep to install PyTorch?

@k-okada
Actually, installing pytorch by rosdep is difficult, because of its dependency on cuda.
So I decided to put install script: jsk_perception/scripts/install_pytorch.sh

@k-okada
Copy link
Member

k-okada commented Mar 28, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 28, 2017 via email

@k-okada
Copy link
Member

k-okada commented Mar 28, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 28, 2017 via email

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 29, 2017 via email

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

Which version of cuda is installed with apt? 7.5 or 8.0?

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 29, 2017

Then, we should set nocuda as the default?

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

But you said 8 was not for T, didn't you?

@wkentaro
Copy link
Member Author

So, we should set http://download.pytorch.org/whl/cu80/torch-0.1.10.post2-cp27-none-linux_x86_64.whl for download target of python-torch rosdep key?

@k-okada
Copy link
Member

k-okada commented Mar 29, 2017 via email

@wkentaro
Copy link
Member Author

PyTorch supports only cuda 7.5 and 8.0, not 5.
And I know people use both cuda 7.5 and 8.0, and that's my concern if I set cuda8.0 as the default.
I think cuda8.0 is more popular these days, though.

@wkentaro
Copy link
Member Author

So possibly, current best choice using rosdep is

python-torch-pip:
  osx:
    packages: [http://download.pytorch.org/whl/torch-0.1.10.post1-cp27-none-macosx_10_7_x86_64.whl]
  ubuntu:
    packages: [http://download.pytorch.org/whl/cu80/torch-0.1.10.post2-cp27-none-linux_x86_64.whl]

@wkentaro
Copy link
Member Author

But I think it is unlikely that the PR was merged if I send to rosdistro, because it is environment specific cuda-80.
Another idea was adding python-torch-cuda80-pip and python-torch-cuda75-pip but it is useless because we can't use if condition in package.xml.

@k-okada
Copy link
Member

k-okada commented Mar 30, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 30, 2017

For example, we're strongly assuming that everyone using 14.04 / Indigo for
jsk-ros-pkg, start-jsk, and if someone using 16.06 Kinetic, we'll assuming
those people
should fix their problem by themselves, very quickly.

IMO, I don't think so, and most of programs work on hydro, indigo, jade, and (kinetic). And I assume Ubuntu 12.04,14.04 (macOS is optional for me).

But it's ok.
My objective is the use of PyTorch in jsk_perception, and maybe I can abandon the automatic installation by rosdep or a script.
I'm not sure why you would like to use a single url not python script?
if we write like below: ok for you?

if (EXISTS /usr/local/cuda-8.0/include/cuda.h)
  add_custom_command(COMMAND pip install http://torch-cuda-80 DEPENDS /usr/local/lib/python2.7/dist-packages/torch)
else if (EXISTS /usr/local/cuda-7.5/include/cuda.h)
  add_custom_command(COMMAND pip install http://torch-cuda-75 DEPENDS /usr/local/lib/python2.7/dist-packages/torch)
else
  add_custom_command(COMMAND pip install http://torch-cuda-bothOK DEPENDS /usr/local/lib/python2.7/dist-packages/torch)
endif

@k-okada
Copy link
Member

k-okada commented Mar 30, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 30, 2017 via email

@k-okada
Copy link
Member

k-okada commented Mar 30, 2017 via email

@wkentaro
Copy link
Member Author

wkentaro commented Mar 31, 2017

So always installing pytorch-cuda80 can be assumed.

@wkentaro
Copy link
Member Author

Depends on ros/rosdistro#14398

@wkentaro
Copy link
Member Author

wkentaro commented Apr 4, 2017

Installing pytorch by rosdep is currently not possible: ros/rosdistro#14398 (review)

- new file:   install_pytorch.py
- deleted:    install_pytorch.sh
@wkentaro
Copy link
Member Author

wkentaro commented Apr 4, 2017

$ echo $CMAKE_PREFIX_PATH
/home/wkentaro/Projects/jsk_apc/devel:/opt/ros/indigo
$ rosrun jsk_perception install_pytorch.py
$ python
>>> import torch
>>> torch
<module 'torch' from '/home/wkentaro/Projects/jsk_apc/devel/lib/python2.7/dist-packages/torch/__init__.pyc'>

@wkentaro
Copy link
Member Author

wkentaro commented Apr 4, 2017

I suggest an installation process above, and what do you think about that?

@yuyu2172
Copy link

yuyu2172 commented Apr 4, 2017

Why PyTorch?

Its much faster than Chainer.
By using Chainer, we get ~1Hz output with VGA image input, but we get ~5Hz output by using PyTorch.

After making some improvements on Chainer code, I found that Chainer one is faster than Pytorch implementation.
wkentaro/pytorch-fcn#19

                                          
==> Running on GPU: 0 to evaluate 5 times 
==> Testing FCN32s with Chainer           
Elapsed time: 0.24 [s / 5 evals]          
Hz: 20.86 [hz]                            
==> Testing FCN32s with PyTorch           
Elapsed time: 0.29 [s / 5 evals]          
Hz: 17.32 [hz]                            
(general)                                 

Please take this into account.

@wkentaro
Copy link
Member Author

wkentaro commented Apr 4, 2017

Yeah, Chainer's Relu was just a mess..

@yuyu2172
Copy link

yuyu2172 commented Apr 5, 2017

If you are concerned with performance, a rule of thumb is to profile the code by nvvp 🔢

@wkentaro
Copy link
Member Author

wkentaro commented Apr 7, 2017

@k-okada Well, what do you think about how to install pytorch? Can I just raise error message at runtime, to prompt user to install it manually?

@k-okada
Copy link
Member

k-okada commented Apr 12, 2017

Please check multi-gpu training performance and calculate how many GPU required for re-train objects within 45 min.

@k-okada k-okada merged commit 60a7fce into jsk-ros-pkg:master Apr 12, 2017
@k-okada
Copy link
Member

k-okada commented Apr 12, 2017 via email

@wkentaro wkentaro deleted the pytorch_fcn branch April 12, 2017 04:39
@wkentaro
Copy link
Member Author

wkentaro commented Apr 12, 2017

Ok, I'll analyze it.

start-jsk/jsk_apc#2037 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants