Skip to content

Instantly share code, notes, and snippets.

@kris7t
Created July 18, 2012 17:22
Show Gist options
  • Save kris7t/3137573 to your computer and use it in GitHub Desktop.
Save kris7t/3137573 to your computer and use it in GitHub Desktop.
Remote debugging over SSH with JCuda
#!/usr/bin/env bash
HOST="chainstories.szigbp.hu"
PORT="57221"
USER="kris"
REMOTE_PATH="/home/${USER}/bme/ssl"
LOCAL_PATH="/home/${USER}/bme/ssl"
BINDIR="hu.kris.bme.semi_supervised_learning/bin"
JARFILES=(
"weka-3-7-6/weka.jar"
"jcuda-0.4.2.jar"
"jcublas-0.4.2.jar"
"jcusparse-0.4.2.jar"
)
LIBFILES=(
"libJCudaDriver-linux-x86_64.so"
"libJCudaRuntime-linux-x86_64.so"
"libJCublas-linux-x86_64.so"
"libJCublas2-linux-x86_64.so"
"libJCusparse-linux-x86_64.so"
"libJCusparse2-linux-x86_64.so"
)
SSH="/home/kris/bin/gpg-ssh"
RSYNC="/usr/bin/rsync"
JAVA="/usr/bin/java"
SSH_CMD="${SSH} -p ${PORT} ${USER}@${HOST}"
export RSYNC_RSH="${SSH} -p ${PORT}"
RSYNC_CMD="${RSYNC} -zrptLR --progress"
REMOTE_PATH_RSYNC="${USER}@${HOST}:${REMOTE_PATH}"
JAVA_CLASSPATH=$(printf ":${REMOTE_PATH}/%s" "${BINDIR}" "${JARFILES[@]}")
JAVA_CLASSPATH="${JAVA_CLASSPATH:1}"
JAVA_CMD="${JAVA} -Djava.library.path=${REMOTE_PATH} -cp ${JAVA_CLASSPATH}"
ACTION=""
if [ "x$1" = "x" ]; then
ACTION="help"
else
ACTION="$1"
fi
case "$ACTION" in
"help")
echo "Usage:"
echo
echo " $0 help"
echo " Display this message."
echo " $0 sync"
echo " Upload binaries to remote host."
echo " $0 run <MainClass>"
echo " Run <MainClass>."
echo " $0 debug <Port> <MainClass>"
echo " Run <MainClass> in debug mode. Debugger will listen on <Port>."
;;
"sync")
(
cd "${LOCAL_PATH}"
${RSYNC} -zrptLR --progress --delete "${BINDIR}" "${JARFILES[@]}" "${LIBFILES[@]}" "${REMOTE_PATH_RSYNC}"
)
;;
"run")
${SSH_CMD} ${JAVA_CMD} "$2"
;;
"debug")
${SSH_CMD} -L "$2:127.0.0.1:$2" ${JAVA_CMD} -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=$2 "$3"
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment