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
9 changes: 9 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,13 @@
cmake_minimum_required(VERSION 2.8)

set(CMAKE_POSITION_INDEPENDENT_CODE ON)


if(CMAKE_CROSSCOMPILING)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -ldl")
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ldl")
endif()

ADD_SUBDIRECTORY(exe)

# If this variable is defined, a pure cmake build is done end-to-end with no luarocks
Expand Down
28 changes: 28 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
[![Build Status](https://travis-ci.org/torch/distro.svg?branch=master)](https://travis-ci.org/torch/distro)


# Torch for RISCV64

Cross-compiled Torch framework for RISCV64 architecture.

## Quick Setup

```shell script
git clone --recursive <repo-url> torch-riscv
cd torch-riscv
patch -p1 < torch-static.patch
bash install-deps
./install-x86.sh
#The crosscompilation step might still use a standard gcc
#on some steps so we need to manually re-wire it to the riscv one
mkdir -p /tmp/cross-wrappers
cp cross-gcc /tmp/cross-wrappers/gcc
export PATH="/tmp/cross-wrappers:$PATH"
./riscv64_cross_compilation_setup.sh
```

## Requirements

- Ubuntu/Debian Linux
- RISCV64 cross-compiler: `sudo apt install gcc-riscv64-linux-gnu`
- Standard build tools: `sudo apt install cmake build-essential`


#### NOTE: Torch is not actively developed anymore and is in maintenance mode.

Self-contained Torch installation
Expand Down
2 changes: 2 additions & 0 deletions cross-gcc
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#!/bin/bash
exec riscv64-linux-gnu-gcc "$@"
2 changes: 1 addition & 1 deletion exe/luajit-rocks
2 changes: 1 addition & 1 deletion extra/nn
Submodule nn updated from 200ae7 to 1e668e
78 changes: 78 additions & 0 deletions install-x86.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
#!/usr/bin/env bash

#This is a truncated version of the original install.sh script
# which defaults to LUA51 and compiles luarocks to run natievly on the build machine

SKIP_RC=0
BATCH_INSTALL=0

THIS_DIR=$(cd $(dirname $0); pwd)
if [[ "$THIS_DIR" == *" "* ]]; then
echo "$THIS_DIR: Torch cannot install to a path containing whitespace.
Please try a different path, one without any spaces."
exit 1
fi
PREFIX=${PREFIX:-"${THIS_DIR}/install"}
TORCH_LUA_VERSION=${TORCH_LUA_VERSION:-"LUA51"} # by default install LUA51

while getopts 'bsh' x; do
case "$x" in
h)
echo "usage: $0
This script will install Torch and related, useful packages into $PREFIX.

-b Run without requesting any user input (will automatically add PATH to shell profile)
-s Skip adding the PATH to shell profile
"
exit 2
;;
b)
BATCH_INSTALL=1
;;
s)
SKIP_RC=1
;;
esac
done

# Scrub an anaconda/conda install, if exists, from the PATH.
# It has a malformed MKL library (as of 1/17/2015)
OLDPATH=$PATH
if [[ $(echo $PATH | grep conda) ]]; then
export PATH=$(echo $PATH | tr ':' '\n' | grep -v "conda[2-9]\?" | uniq | tr '\n' ':')
fi

echo "Prefix set to $PREFIX"

if [[ `uname` == 'Linux' ]]; then
export CMAKE_LIBRARY_PATH=$PREFIX/include:/opt/OpenBLAS/include:$PREFIX/lib:/opt/OpenBLAS/lib:$CMAKE_LIBRARY_PATH
fi
export CMAKE_PREFIX_PATH=$PREFIX

git submodule update --init --recursive

# If we're on OS X, use clang
if [[ `uname` == "Darwin" ]]; then
# make sure that we build with Clang. CUDA's compiler nvcc
# does not play nice with any recent GCC version.
export CC=clang
export CXX=clang++
fi
# If we're on Arch linux, use gcc v5
if [[ `uname -a` == *"ARCH"* ]]; then
path_to_gcc5=$(which gcc-5)
if [ -x "$path_to_gcc5" ]; then
export CC="$path_to_gcc5"
else
echo "Warning: GCC v5 not found. CUDA v8 is incompatible with GCC v6, if installation fails, consider running \$ pacman -S gcc5"
fi
fi

echo "Installing Lua version: ${TORCH_LUA_VERSION}"
mkdir -p install
mkdir -p build
cd build

cmake .. -DCMAKE_INSTALL_PREFIX="${PREFIX}" -DCMAKE_BUILD_TYPE=Release -DWITH_${TORCH_LUA_VERSION}=ON 2>&1 >>$PREFIX/install.log || exit 1
(make 2>&1 >>$PREFIX/install.log || exit 1) && (make install 2>&1 >>$PREFIX/install.log || exit 1)
cd ..
Loading