Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,5 @@
!launch.sh

# YOUR FILES LISTED BELOW THIS LINE (IMPORTANT: PREPEND !)
!install_torch.sh
# ----------------------------------------------------------------------------
29 changes: 28 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,32 @@ ARG MAJOR=daffy
ARG BASE_TAG=${MAJOR}-${ARCH}
ARG BASE_IMAGE=dt-core


# define base image
FROM duckietown/${BASE_IMAGE}:${BASE_TAG}

ENV PATH /usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH}
ENV LD_LIBRARY_PATH /usr/local/nvidia/lib:/usr/local/nvidia/lib64

ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES all

ENV CUDA_VERSION 10.2.89
ENV CUDA_PKG_VERSION 10-2=$CUDA_VERSION-1
ENV NCCL_VERSION 2.8.4
ENV CUDNN_VERSION 8.1.1.33

ENV PYTORCH_VERSION 1.7.0
ENV PYTORCHVISION_VERSION 0.8.0a0+2f40a48

ENV TENSORRT_VERSION 7.1.3.4

ENV PYCUDA_VERSION 2021.1

ARG PIP_INDEX_URL="https://pypi.org/simple"
ENV PIP_INDEX_URL=${PIP_INDEX_URL}

RUN ln -s /usr/local/cuda-10.2 /usr/local/cuda
# define repository path
ARG REPO_NAME
ARG REPO_PATH="${CATKIN_WS_DIR}/src/${REPO_NAME}"
Expand All @@ -34,13 +57,17 @@ RUN apt-get update \

# install python dependencies
RUN pip install -r ${REPO_PATH}/dependencies-py.txt

# copy the source code
COPY . "${REPO_PATH}/"

RUN pwd ${REPO_PATH}/
RUN ls ${REPO_PATH}/

RUN cp -r "${REPO_PATH}/packages/dt-core" "${CATKIN_WS_DIR}/src/"
RUN rm -r "${REPO_PATH}/packages/dt-core"

RUN bash ${REPO_PATH}/install_torch.sh

# build packages
RUN . /opt/ros/${ROS_DISTRO}/setup.sh && \
catkin build \
Expand Down
1 change: 1 addition & 0 deletions dependencies-py.txt
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
# LIST YOUR PYTHON PACKAGES HERE
# torch
44 changes: 44 additions & 0 deletions install_torch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash

set -e

apt-get update
apt-get install -y --no-install-recommends \
libopenblas-base \
libopenmpi-dev \
g++-8 \
unzip
rm -rf /var/lib/apt/lists/*

# download PyTorch
echo "Downloading PyTorch v${PYTORCH_VERSION}..."
PYTORCH_WHEEL_NAME="torch-${PYTORCH_VERSION}.cuda.cudnn-cp38-cp38-linux_aarch64.whl"
WHEEL_URL="https://duckietown-public-storage.s3.amazonaws.com/assets/python/wheels/${PYTORCH_WHEEL_NAME}"
wget -q "${WHEEL_URL}" -O "/tmp/${PYTORCH_WHEEL_NAME}"
# install PyTorch
echo "Installing PyTorch v${PYTORCH_VERSION}..."
pip3 install "/tmp/${PYTORCH_WHEEL_NAME}"
rm "/tmp/${PYTORCH_WHEEL_NAME}"

# download TensorRT
echo "Downloading TensorRT v${TENSORRT_VERSION}..."
TENSORRT_WHEEL_NAME=tensorrt-${TENSORRT_VERSION}-cp38-cp38-linux_aarch64.whl
TENSORRT_WHEEL_URL="https://duckietown-public-storage.s3.amazonaws.com/assets/python/wheels/${TENSORRT_WHEEL_NAME}"
wget -q "${TENSORRT_WHEEL_URL}" -O "/tmp/${TENSORRT_WHEEL_NAME}"
# install TensorRT
echo "Installing TensorRT v${TENSORRT_VERSION}..."
pip3 install "/tmp/${TENSORRT_WHEEL_NAME}"
rm "/tmp/${TENSORRT_WHEEL_NAME}"

# download PyCUDA
echo "Downloading PyCUDA v${PYCUDA_VERSION}..."
PYCUDA_WHEEL_NAME=pycuda-${PYCUDA_VERSION}-cp38-cp38-linux_aarch64.whl
PYCUDA_WHEEL_URL="https://duckietown-public-storage.s3.amazonaws.com/assets/python/wheels/${PYCUDA_WHEEL_NAME}"
wget -q "${PYCUDA_WHEEL_URL}" -O "/tmp/${PYCUDA_WHEEL_NAME}"
# install PyCUDA
echo "Installing PyCUDA v${PYCUDA_VERSION}..."
pip3 install "/tmp/${PYCUDA_WHEEL_NAME}"
rm "/tmp/${PYCUDA_WHEEL_NAME}"

# clean
pip3 uninstall -y dataclasses
9 changes: 5 additions & 4 deletions launch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,12 @@ set -e
# YOUR CODE BELOW THIS LINE
# ----------------------------------------------------------------------------
echo "This is an empty launch script. Update it to launch your application."
#roslaunch circle_drive circle_drive.launch

roslaunch circle_drive circle_drive.launch
#roslaunch duckietown_demos lane_following.launch
roslaunch --wait circle_drive indefinite_navigation2.launch &
#roslaunch --wait circle_drive indefinite_navigation2.launch &

#roslaunch --wait <package> launchfile.launch &
sleep 5
#sleep 5
# we put a short sleep in here because rostopic will fail if there's no roscore yet
rostopic pub /$VEHICLE_NAME/fsm_node/mode duckietown_msgs/FSMState '{header: {}, state: "LANE_FOLLOWING"}'
#rostopic pub /$VEHICLE_NAME/fsm_node/mode duckietown_msgs/FSMState '{header: {}, state: "LANE_FOLLOWING"}'
9 changes: 5 additions & 4 deletions packages/circle_drive/scripts/circle_drive.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import rospy
from duckietown.dtros import DTROS, NodeType
from duckietown_msgs.msg import Twist2DStamped, StopLineReading
import torch

class MyNode(DTROS):

Expand All @@ -20,15 +21,15 @@ def run(self):
# publish message every 1 second
rate = rospy.Rate(0.5) # 1Hz
while not rospy.is_shutdown():
continue
msg = Twist2DStamped()
msg.v = 0.0
msg.v = 0.1
msg.omega = 1.0
rospy.loginfo("Publishing message")
rospy.loginfo("Publishing message run")
rospy.loginfo("GPU available: {}".format(torch.cuda.is_available()))
self.pub.publish(msg)
rate.sleep()
msg.omega = 0.0
rospy.loginfo("Publishing message -")
rospy.loginfo("Publishing message stop")
self.pub.publish(msg)
rate.sleep()

Expand Down