使用Doker创建GPGPU仿真环境

拉取英伟达官方镜像

docker pull nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04

docker 启动 容器名称:gpgpusim0 物理挂载地址:D:/docker/gpgpusim/gpgpusim1 这里nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04也可以换成镜像号

docker run --name gpgpusim0 -it -v D:/docker/gpgpusim/gpgpusim1:/root/sim/ nvcr.io/nvidia/cuda:10.1-devel-ubuntu16.04 /bin/bash

进入容器

# make directories

echo "export HOME=/root" >> ~/.bashrc
mkdir /root/git && mkdir /root/install

# install packages

apt-get update -y 
apt-get install -yq build-essential apt-utils gcc-4.8 gcc-4.9
g++-4.8 g++-4.9 wget git vim linux-headers-4.4.0-194 linux-headers-4.4.0-194-generic
libxi-dev libxmu-dev libglu1-mesa-dev kmod libxml2

# setup gcc versions

update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.8 60 
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.9 50 
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.8 60 
update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-4.9 50 
update-alternatives --set gcc /usr/bin/gcc-4.9 
update-alternatives --set g++ /usr/bin/g++-4.9 

# append variables to the bashrc

echo "export PATH=/usr/local/cuda/bin:$PATH" >> ~/.bashrc 
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64" >> ~/.bashrc 
echo "export RTE_SDK=/root/install/dpdk-16.11/build" >> ~/.bashrc

# setup dpdk

cd /root/install && tar -xzvf dpdk-16.11.tar.gz 
cd dpdk-16.11 &&  make config T=x86_64-native-linuxapp-gcc 
make RTE_KERNELDIR=/lib/modules/4.4.0-194-generic/build 
ln -s /root/install/dpdk-16.11/mk /root/install/dpdk-16.11/build/mk 
ln -s /root/install/dpdk-16.11/build /root/install/dpdk-16.11/build/x86_64-native-linuxapp-gcc

# setup cuda sdk

wget -O /root/install http://developer.download.nvidia.com/compute/cuda/6_5/rel/installers/cuda_6.5.14_linux_64.run
wget -O /root/install https://developer.download.nvidia.com/compute/cuda/4_0/sdk/gpucomputingsdk_4.0.17_linux.run
echo 'export  export NVIDIA_COMPUTE_SDK_LOCATION=/root//install/NVIDIA_GPU_Computing_SDK' >> ~/.bashrc
source ~/.bashrc
cd /root/install && sh cuda_6.5.14_linux_64.run -silent --override --toolkit --samples && \
ln -s /usr/local/cuda-6.5 /usr/local/cuda && \
/usr/local/cuda/bin/nvcc --version

wget -O /root/install/cuda_10.0.130_410.48_linux.run https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux

cd /root/install && sh cuda_10.1.105_418.39_linux.run --silent --samples --samplespath=/usr/local/cuda-10.1/ && \
ln -s /usr/local/cuda-10.1 /usr/local/cuda


echo 'export CUDA_INSTALL_PATH=/usr/local/cuda' >> ~/.bashrc
echo 'export PATH=$CUDA_INSTALL_PATH/bin:$PATH' >> ~/.bashrc
echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CUDA_INSTALL_PATH/lib64' >> ~/.bashrc
source ~/.bashrc

# setup megakv  

cd /root/git && git clone https://github.com/pzrq/megakv.git && \
update-alternatives --set gcc /usr/bin/gcc-4.8 && \
update-alternatives --set g++ /usr/bin/g++-4.8

export PATH=/usr/local/cuda/bin:$PATH && \
export LD_LIBRARY_PATH=/usr/local/cuda/lib64 && \
export RTE_SDK=/root/install/dpdk-16.11/build && \
cd /root/git/megakv/libgpuhash && make && cd /root/git/megakv/src && make

下载gpgpu

git clone https://github.com/gpgpu-sim/gpgpu-sim_distribution
cd gpgpu-sim_distribution

环境编译

source setup_environment

Make

make
make docs
make cleandocs
make docs

遇到缺少graphviz包问题

apt-get install graphviz
apt install doxygen-latex

再次编译

make docs

建立测试文件

 vim hello.cu
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
#include <stdio.h>

__global__ void kernel(void) {

}

int main() {

    kernel << <1, 1 >> > ();
    printf("Hello world!\n");
    return 0;

}

nvcc编译

nvcc --cudart shared -o hello hello.cu
ldd hello

得到 helllo.out文件

重新编译环境

source setup_environment release

运行

./hello

得到详细数据

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值