Commit ed690e77 authored by Katharina Höflich's avatar Katharina Höflich

Merge branch 'add-initial-dev-environment' into 'master'

Add initial dev environment and Singularity example

See merge request !1
parents ae2faea4 08262853
Pipeline #26252 passed with stage
in 48 seconds
docker-build-tags:
image: docker:latest
stage: build
tags:
- docker-machine
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
only:
- tags
docker-build:
image: docker:latest
stage: build
tags:
- docker-machine
variables:
DOCKER_DRIVER: overlay2
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD" $CI_REGISTRY
script:
- docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG"
except:
- tags
FROM centos:8
# Nvidia HPC compiler SDK setup documentation
# https://docs.nvidia.com/hpc-sdk/hpc-sdk-install-guide/index.html
# https://docs.nvidia.com/hpc-sdk/eula/index.html
# https://developer.nvidia.com/nvidia-hpc-sdk-download
RUN yum update -y \
# Install CentOS development tools and provide Nvidia compiler GCC dependencies
# List of the following: optional, default, mandatory. Tells dnf which type of packages in groups will be installed when ‘groupinstall’ is called. Default is: default, mandatory. (https://dnf.readthedocs.io/en/latest/conf_ref.html)
&& yum --setopt=group_package_types=mandatory group install "Development Tools" -y \
# Add optional GCC Fortran compiler
&& yum install gcc-gfortran -y \
# Provide man page support
&& yum install man-pages man-db man -y \
# Clean-up package manager
&& yum clean all
# https://docs.nvidia.com/hpc-sdk/hpc-sdk-install-guide/index.html
# Note: Any changes to your gcc compilers requires you to reinstall the HPC SDK.
ARG NVIDIA_SDK_VERSION=nvhpc_2020_207_Linux_x86_64_cuda_multi
ARG SDK_INSTALL_DIR=/nvidia/hpc_sdk
# do: https://developer.download.nvidia.com/hpc-sdk/md5sum.txt
# Install system dependencies
RUN yum update -y \
&& yum install wget -y \
&& yum clean all
# Install Nvidia compiler SDK
RUN wget --quiet https://developer.download.nvidia.com/hpc-sdk/${NVIDIA_SDK_VERSION}.tar.gz \
&& tar xpzf ${NVIDIA_SDK_VERSION}.tar.gz \
&& rm -f ${NVIDIA_SDK_VERSION}.tar.gz \
&& export NVHPC_SILENT=true && export NVHPC_INSTALL_DIR=$SDK_INSTALL_DIR && export NVHPC_INSTALL_TYPE=single \
&& ${NVIDIA_SDK_VERSION}/install \
# Clean-up obsolete files/directories
&& rm -rf ${NVIDIA_SDK_VERSION}
# Set-up Nvidia SDK environment settings
ENV NVARCH=Linux_x86_64 \
NVCOMPILERS=$SDK_INSTALL_DIR \
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/20.7/compilers/man \
PATH=$NVCOMPILERS/$NVARCH/20.7/compilers/bin:$PATH \
PATH=$NVCOMPILERS/$NVARCH/20.7/comm_libs/mpi/bin:$PATH \
MANPATH=$MANPATH:$NVCOMPILERS/$NVARCH/20.7/comm_libs/mpi/man
# Further useful stuff
RUN yum update -y \
&& yum install vim git -y \
&& yum clean all
# nvidia-compiler-sdk-container
# Nvidia compiler SDK container
C, C++ and FORTRAN compiler environment for GPU programming
\ No newline at end of file
A ready-to-use C, C++ and FORTRAN compiler environment for GPU programming.
```shell
$ singularity shell --nv ${NVIDIA_IMAGE_PATH}
$ git clone git@git.geomar.de:scientific_computing_infrastructure/nvidia-compiler-sdk-container.git
$ cd nvidia-compiler-sdk-container/test_nvidia_compilers/
$ bash run_tests.sh
Test Passed
Test Passed
```
docker build -t nvidia_sdk .
docker save --output=nvidia_sdk.tar nvidia_sdk:latest
singularity build nvidia_sdk.sif docker-archive://nvidia_sdk.tar
# GNU compiler examples
These should compile/execute without errors.
## References
* https://docs.nvidia.com/hpc-sdk/hpc-sdk-install-guide/index.html#install-linux-prep
* https://en.wikibooks.org/wiki/Fortran/Fortran_examples#FORTRAN_77
* https://en.wikibooks.org/wiki/Fortran/Fortran_examples#Fortran_90
#include <stdio.h>
int main() {
printf("Hello, world!\n");
return 0;
}
#include <iostream>
int main() {
std::cout << "Hello, world!\n";
return 0;
}
PROGRAM HELLO
PRINT '(A)', 'Hello, world!'
STOP
END PROGRAM
program hello
write(*,*) "Hello, world!"
end program hello
#!/bin/bash
gcc -m64 -o hello_64_c hello.c
g++ -m64 -o hello_64_cpp hello.cpp
./hello_64_c
./hello_64_cpp
gfortran -o hello_f hello.f
gfortran -o hello_f90 hello.f90
./hello_f
./hello_f90
# Nvidia compiler examples
These should compile/execute without errors.
The `*.cuf` executables only run correctly with a GPU device available.
## References
* Introduction to CUDA Fortran; https://on-demand.gputechconf.com/gtc/2013/presentations/S3050-Intro-to-CUDA-Fortran.pdf
#!/bin/bash
nvfortran -o test_cpu_f90 test_cpu.f90
./test_cpu_f90
nvfortran -o test_gpu_cuf test_gpu.cuf
./test_gpu_cuf
program copyData
! use cudafor
implicit none
integer, parameter :: n = 256
real :: a(n), b(n)
! real, device :: a_d(n), b_d(n)
a = 1.0
! a_d = a
! b_d = a_d
b = a
if (all(a == b)) &
write(*,*) 'Test Passed'
end program copyData
program copyData
use cudafor
implicit none
integer, parameter :: n = 256
real :: a(n), b(n)
real, device :: a_d(n), b_d(n)
a = 1.0
a_d = a
b_d = a_d
b = b_d
if (all(a == b)) &
write(*,*) 'Test Passed'
end program copyData
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment