Skip to content

Commit 616fc2b

Browse files
author
Chris Maunder
committed
Corrected .NET / CUDA install on Linux
1 parent 9b0e2fe commit 616fc2b

File tree

4 files changed

+95
-28
lines changed

4 files changed

+95
-28
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ We will be constantly expanding the feature list.
120120

121121
#### Supported Development Environments
122122

123-
This current release works best with Visual Studio Code on Windows 10+. Ubuntu, Debian and macOS (both Intel and Apple Silicon). Visual Studio 2019+ support is included for Windows 10+.
123+
This current release works best with Visual Studio Code on Windows 10+. Ubuntu 22.04+, Debian and macOS (both Intel and Apple Silicon). Visual Studio 2019+ support is included for Windows 10+.
124124

125125
The current release provides support for CPU on each platform, DirectML on Windows, CUDA on Windows and Linux, support for Apple Silicon GPUs, RockChip NPUs and Coral.AI TPUs. Support depends on the module itself.
126126

devops/install/dotnet-install.sh

Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,14 @@ get_machine_architecture() {
329329
echo "loongarch64"
330330
return 0
331331
;;
332+
riscv64)
333+
echo "riscv64"
334+
return 0
335+
;;
336+
powerpc|ppc)
337+
echo "ppc"
338+
return 0
339+
;;
332340
esac
333341
fi
334342

@@ -417,11 +425,17 @@ get_normalized_architecture_for_specific_sdk_version() {
417425
# args:
418426
# version or channel - $1
419427
is_arm64_supported() {
420-
#any channel or version that starts with the specified versions
421-
case "$1" in
422-
( "1"* | "2"* | "3"* | "4"* | "5"*)
423-
echo false
424-
return 0
428+
# Extract the major version by splitting on the dot
429+
major_version="${1%%.*}"
430+
431+
# Check if the major version is a valid number and less than 6
432+
case "$major_version" in
433+
[0-9]*)
434+
if [ "$major_version" -lt 6 ]; then
435+
echo false
436+
return 0
437+
fi
438+
;;
425439
esac
426440

427441
echo true
@@ -571,12 +585,10 @@ is_dotnet_package_installed() {
571585
local dotnet_package_path="$(combine_paths "$(combine_paths "$install_root" "$relative_path_to_package")" "$specific_version")"
572586
say_verbose "is_dotnet_package_installed: dotnet_package_path=$dotnet_package_path"
573587

574-
if [ ! -d "$dotnet_package_path" ]; then
575-
# say_err "$dotnet_package_path does not exist"
576-
return 1
577-
else
578-
# say_err "$dotnet_package_path exists"
588+
if [ -d "$dotnet_package_path" ]; then
579589
return 0
590+
else
591+
return 1
580592
fi
581593
}
582594

@@ -958,6 +970,37 @@ get_absolute_path() {
958970
return 0
959971
}
960972

973+
# args:
974+
# override - $1 (boolean, true or false)
975+
get_cp_options() {
976+
eval $invocation
977+
978+
local override="$1"
979+
local override_switch=""
980+
981+
if [ "$override" = false ]; then
982+
override_switch="-n"
983+
984+
# create temporary files to check if 'cp -u' is supported
985+
tmp_dir="$(mktemp -d)"
986+
tmp_file="$tmp_dir/testfile"
987+
tmp_file2="$tmp_dir/testfile2"
988+
989+
touch "$tmp_file"
990+
991+
# use -u instead of -n if it's available
992+
if cp -u "$tmp_file" "$tmp_file2" 2>/dev/null; then
993+
override_switch="-u"
994+
fi
995+
996+
# clean up
997+
rm -f "$tmp_file" "$tmp_file2"
998+
rm -rf "$tmp_dir"
999+
fi
1000+
1001+
echo "$override_switch"
1002+
}
1003+
9611004
# args:
9621005
# input_files - stdin
9631006
# root_path - $1
@@ -969,15 +1012,7 @@ copy_files_or_dirs_from_list() {
9691012
local root_path="$(remove_trailing_slash "$1")"
9701013
local out_path="$(remove_trailing_slash "$2")"
9711014
local override="$3"
972-
local osname="$(get_current_os_name)"
973-
local override_switch=$(
974-
if [ "$override" = false ]; then
975-
if [ "$osname" = "linux-musl" ]; then
976-
printf -- "-u";
977-
else
978-
printf -- "-n";
979-
fi
980-
fi)
1015+
local override_switch="$(get_cp_options "$override")"
9811016

9821017
cat | uniq | while read -r file_path; do
9831018
local path="$(remove_beginning_slash "${file_path#$root_path}")"
@@ -1030,8 +1065,7 @@ extract_dotnet_package() {
10301065

10311066
say "extract_dotnet_package: zip_path=$zip_path, temp_out_path=$temp_out_path, out_path=$out_path"
10321067

1033-
if [ ! -d "$temp_out_path" ]; then mkdir "$temp_out_path"; fi
1034-
1068+
10351069
local failed=false
10361070
if [ "$quiet" != true ]; then
10371071
tar -xzf "$zip_path" -C "$temp_out_path" > /dev/null || failed=true
@@ -1045,7 +1079,7 @@ extract_dotnet_package() {
10451079

10461080
validate_remote_local_file_sizes "$zip_path" "$remote_file_size"
10471081

1048-
# rm -rf "$temp_out_path"
1082+
rm -rf "$temp_out_path"
10491083
if [ -z ${keep_zip+x} ]; then
10501084
rm -f "$zip_path" && say_verbose "Temporary archive file $zip_path was removed"
10511085
fi
@@ -1761,7 +1795,7 @@ do
17611795
zip_path="$1"
17621796
;;
17631797
-?|--?|-h|--help|-[Hh]elp)
1764-
script_name="$(basename "$0")"
1798+
script_name="dotnet-install.sh"
17651799
echo ".NET Tools Installer"
17661800
echo "Usage:"
17671801
echo " # Install a .NET SDK of a given Quality from a given Channel"
@@ -1892,4 +1926,4 @@ fi
18921926

18931927
say "Note that the script does not resolve dependencies during installation."
18941928
say "To check the list of dependencies, go to https://learn.microsoft.com/dotnet/core/install, select your operating system and check the \"Dependencies\" section."
1895-
say "Installation finished successfully."
1929+
say "Installation finished successfully."

devops/install/install_cuDNN.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,17 @@
3737
# sudo apt-get update -y
3838
# sudo apt-get -y install cuda-X.Y
3939

40+
if [ "$1" == "" ]; then
41+
echo "Please provide the CUDA version for which to install cuDNN"
42+
exit
43+
fi
4044

4145
# cuda_version=$1
4246
# Get major.minor CUDA version
4347
cuda_version=$(cut -d '.' -f 1,2 <<< "$1")
4448

4549
# This script is intended to be called from setup.sh, which includes architecture
46-
# and os vars as well as writeline methods. If we don't find them, do quick checks
50+
# and os vars as well as writeLine methods. If we don't find them, do quick checks
4751

4852
if [[ $(type -t writeLine) != function ]]; then
4953

@@ -97,7 +101,7 @@ writeLine "Setting up CUDA ${cuda_version} and cuDNN" $color_info
97101
# ==============================================================================
98102
# GET SETTINGS
99103

100-
cuda_GPGpublicKey=""
104+
cuda_GPGpublicKey="3bf863cc"
101105

102106
case "$cuda_version" in
103107
"12.2") cuda_version_full="12.2.1"; cuda_GPGpublicKey="3bf863cc" ;;

src/scripts/utils.sh

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,6 +755,7 @@ function setupDotNet () {
755755
if [ "$isAdmin" = true ] || [ "$attemptSudoWithoutAdminRights" = true ]; then
756756
if [ "$os" = "linux" ]; then
757757

758+
# Disabled this due to it not proving reliable
758759
if [ "$os_name" = "debian-SKIP" ]; then
759760

760761
wget https://packages.microsoft.com/config/debian/${os_vers}/packages-microsoft-prod.deb -O packages-microsoft-prod.deb >/dev/null
@@ -767,7 +768,29 @@ function setupDotNet () {
767768
sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-$requestedNetMajorMinorVersion >/dev/null
768769
fi
769770

771+
# .NET 9 is almost good to go
772+
elif [ "$os_name" == "ubuntu" ] && [ "$requestedNetMajorVersion" == "9" ]; then
773+
774+
# TODO: Change this to a " >= 24.10"
775+
if [ "$os_vers" == "24.10" ]; then
776+
if [ "$requestedType" = "sdk" ]; then
777+
sudo apt-get update && sudo apt-get install -y dotnet-sdk-$requestedNetMajorMinorVersion >/dev/null
778+
else
779+
sudo apt-get update && sudo apt-get install -y aspnetcore-runtime-$requestedNetMajorMinorVersion >/dev/null
780+
fi
781+
else
782+
# .NET 9 is still not fully released. But we know a guy who knows a guy...
783+
# TODO: This also works for NET 6 & 7, Ubuntu 24.04, and .NET 9, Ubuntu 22.04 & 24.04
784+
sudo add-apt-repository ppa:dotnet/backports -y
785+
sudo apt install "dotnet${requestedNetMajorVersion}" -y
786+
fi
787+
788+
# For everyone else, use The Script
770789
else
790+
791+
# Needed if we're installing .NET without an installer to help us
792+
installAptPackages "ca-certificates libc6 libgcc-s1 libicu74 liblttng-ust1 libssl3 libstdc++6 libunwind8 zlib1g"
793+
771794
if [ "$architecture" = 'arm64' ]; then
772795
# installs in /opt/dotnet
773796
if [ $verbosity = "quiet" ]; then
@@ -785,7 +808,13 @@ function setupDotNet () {
785808
fi
786809
fi
787810
fi
811+
788812
else
813+
# macOS
814+
815+
# Needed if we're installing .NET without an installer to help us
816+
# installAptPackages "ca-certificates libc6 libgcc-s1 libicu74 liblttng-ust1 libssl3 libstdc++6 libunwind8 zlib1g"
817+
789818
if [ $verbosity = "quiet" ]; then
790819
sudo bash "${installScriptsDirPath}/dotnet-install.sh" --install-dir "${dotnet_path}" --channel "$requestedNetMajorMinorVersion" --runtime "$requestedType" "--quiet"
791820
elif [ $verbosity = "loud" ]; then
@@ -852,7 +881,7 @@ function setupDotNet () {
852881
echo "sudo rm /etc/apt/sources.list.d/microsoft-prod.list"
853882
echo "sudo apt-get update"
854883
echo "# Install .NET SDK"
855-
echo "sudo apt-get install dotnet-sdk-${requestedNetVersion}"
884+
echo "sudo apt-get install dotnet-sdk-${requestedNetMajorMinorVersion}"
856885
else
857886
writeLine ".NET was not installed correctly. You may need to install .NET manually" $color_error
858887
writeLine "See https://learn.microsoft.com/en-us/dotnet/core/install/macos for downloads" $color_error

0 commit comments

Comments
 (0)