スキップしてメイン コンテンツに移動

ROS noetic + Anaconda3 + YOLOv5

Reference

https://conda.io/projects/conda/en/latest/commands.html

 

sip2@sip2-2021:~$ source ~/anaconda3/etc/profile.d/conda.sh
 

sip2@sip2-2021:~$ conda info --e
# conda environments:
#
base                  *  /home/sip2/anaconda3
py38-test                /home/sip2/anaconda3/envs/py38-test
py38-torch1-12-1         /home/sip2/anaconda3/envs/py38-torch1-12-1


sip2@sip2-2021:~$ conda create -n py38-torch1-12-1-gpu-od --clone py38-torch1-12-1
Source:      /home/sip2/anaconda3/envs/py38-torch1-12-1
Destination: /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od


sip2@sip2-2021:~$ conda activate py38-torch1-12-1-gpu-od

sip2@sip2-2021:~$ mkdir -p ~/catkin_od/src

sip2@sip2-2021:~$ cd catkin_od

sip2@sip2-2021:~/catkin_od$ catkin_make

...

-- Configuring done
-- Generating done
-- Build files have been written to: /home/sip2/catkin_od/build
####
#### Running command: "make -j16 -l16" in "/home/sip2/catkin_od/build"
####


(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ cd src/object_detection/scripts/yolov5/
 

(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od/src/object_detection/scripts/yolov5$ pip install -r requirements.txt

(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ source devel/setup.bash


(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ rosrun object_detection ros_yolov5_multiple.py
Traceback (most recent call last):
  File "/home/sip2/catkin_od/src/object_detection/scripts/yolov5/ros_yolov5_multiple.py", line 4, in <module>
    import rospy
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/__init__.py", line 49, in <module>
    from .client import spin, myargv, init_node, \
  File "/opt/ros/noetic/lib/python3/dist-packages/rospy/client.py", line 52, in <module>
    import roslib
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/__init__.py", line 50, in <module>
    from roslib.launcher import load_manifest  # noqa: F401
  File "/opt/ros/noetic/lib/python3/dist-packages/roslib/launcher.py", line 42, in <module>
    import rospkg
ModuleNotFoundError: No module named 'rospkg'


(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ pip install rospkg
Collecting rospkg
  Downloading rospkg-1.4.0-py3-none-any.whl (36 kB)
Collecting distro>=1.4.0
  Downloading distro-1.7.0-py3-none-any.whl (20 kB)
Collecting catkin-pkg
  Downloading catkin_pkg-0.5.2-py3-none-any.whl (76 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 76.1/76.1 kB 2.2 MB/s eta 0:00:00
Requirement already satisfied: PyYAML in /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages (from rospkg) (6.0)
Requirement already satisfied: python-dateutil in /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages (from catkin-pkg->rospkg) (2.8.2)
Collecting docutils
  Downloading docutils-0.19-py3-none-any.whl (570 kB)
     ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 570.5/570.5 kB 9.0 MB/s eta 0:00:00
Requirement already satisfied: setuptools in /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages (from catkin-pkg->rospkg) (63.4.1)
Requirement already satisfied: pyparsing in /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages (from catkin-pkg->rospkg) (3.0.9)
Requirement already satisfied: six>=1.5 in /home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages (from python-dateutil->catkin-pkg->rospkg) (1.16.0)
Installing collected packages: docutils, distro, catkin-pkg, rospkg
Successfully installed catkin-pkg-0.5.2 distro-1.7.0 docutils-0.19 rospkg-1.4.0


(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ rosrun object_detection ros_yolov5_multiple.py
Traceback (most recent call last):
  File "/home/sip2/catkin_od/src/object_detection/scripts/yolov5/ros_yolov5_multiple.py", line 26, in <module>
    import skimage
ModuleNotFoundError: No module named 'skimage'

(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ pip install scikit-image


(py38-torch1-12-1-gpu-od) sip2@sip2-2021:~/catkin_od$ rosrun object_detection ros_yolov5_multiple.py

  File "/home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages/torch/nn/modules/upsampling.py", line 154, in forward
    recompute_scale_factor=self.recompute_scale_factor)
  File "/home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1207, in __getattr__
    raise AttributeError("'{}' object has no attribute '{}'".format(
AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'

"/home/sip2/anaconda3/envs/py38-torch1-12-1-gpu-od/lib/python3.8/site-packages/torch/nn/modules/upsampling.py"

before

def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners,
recompute_scale_factor=self.recompute_scale_factor)


after

def forward(self, input: Tensor) -> Tensor:
return F.interpolate(input, self.size, self.scale_factor, self.mode, self.align_corners
)



Test result




コメント

このブログの人気の投稿

[참고] ROS kinetic에서 WebCam 사용하기 (Ubuntu 16.04)

Reference: 1. https://github.com/bosch-ros-pkg/usb_cam/issues/53  2. http://zumashi.blogspot.jp/2016/12/ros-kinetic-usb-cam.html  3. http://cafe.naver.com/openrt/5963 위의 사이트들을 참고하여 ROS Kinetic에서 Logitech WebCam C270의 동작을 확인했습니다. $ cd ~/catkin_ws/src $ git clone https://github.com/bosch-ros-pkg/usb-cam.git $ cd .. $ catkin_make WebCam test $ roscore $ rosrun usb_cam usb_cam_node $ rosrun image_view image_view image:=/usb_cam/image_raw $ rosrun rviz rviz 1) By display type>rviz>image 2) Image topic: /usb_cam/image_raw --> 왼쪽 하단과 같이 WebCam이 잘 동작하는 것을 확인했습니다.

[vscode] TImeout waiting for debugger connection

이제까지 잘 동작하던 비주얼 스튜디오 코드가 위와 같은 에러 메세지를 내면서 갑자기 디버깅이 안되서 인터넷을 검색한 결과.. vscode의 User Setting에서 검색창에 python.terminal.activateEnvironment을 입력하여 true로 설정되어 있는 값을 false로 변환하면 된다. 

Anaconda을 이용하여 ROS + Tensorflow 함께 사용하기

-- CUDA, cuDNN 버전확인 https://stackoverflow.com/questions/41714757/how-to-find-cuda-version-in-ubuntu/42122965 $ nvcc --version cuda8.0, cudnn6.0 -- 아나콘다 python2.7 버전 인스톨 https://www.anaconda.com/download/#linux python3.x이랑 ROS 같이 써보려고 했는데, 아직 실력이 부족해서 그런지 실패.. $ bash Anaconda2-5.3.0-Linux-x86_64.sh $ source ~/.bashrc $ python -V Python 2.7.15 :: Anaconda, Inc. $ conda create -n tf14 pip python=2.7 $ source activate tf14 -- ROS 관련 패키지 인스톨 (tf14) $ pip install --upgrade pip (tf14) $ pip install -U rosinstall msgpack empy defusedxml netifaces --CUDA, cuDNN, CPU/GPU을 사양에 맞춰서 tensorflow download https://github.com/mind/wheels#mkl (tf14) $ pip install tensorflow-1.4.0-cp27-cp27mu-linux_x86_64.whl 잘 설치가 되었는지 Hello, tensorflow 실행 (tf14) $ python Python 2.7.15 |Anaconda, Inc.| (default, May  1 2018, 23:32:55) [GCC 7.2.0] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> i