PageSourceSearch

https://pytorch.kr/assets/quick-start-module.js

js pytorch.kr collected 2026-09-25 22:57:23 UTC 20,584 bytes, 285 lines download raw bytes

1// Keys are Substrings as diplayed by navigator.platform
2var supportedOperatingSystems = new Map([
3  ['linux', 'linux'],
4  ['mac', 'macos'],
5  ['win', 'windows'],
6]);
7
8var archInfoMap = new Map([
9  ['cuda', {title: "CUDA", platforms: new Set(['linux', 'windows'])}],
10  ['rocm', {title: "ROCm", platforms: new Set(['linux'])}],
11  ['accnone', {title: "CPU", platforms: new Set(['linux', 'macos', 'windows'])}]
12]);
13
14let version_map={"nightly": {"accnone": ["cpu", ""], "cuda.x": ["cuda", "12.6"], "cuda.y": ["cuda", "13.0"], "cuda.z": ["cuda", "13.2"], "rocm5.x": ["rocm", "10.0"]}, "release": {"accnone": ["cpu", ""], "cuda.x": ["cuda", "12.6"], "cuda.y": ["cuda", "13.0"], "cuda.z": ["cuda", "13.2"], "rocm5.x": ["rocm", "7.14"]}}
15let stable_version="Stable (2.14.0)";
16
17var default_selected_os = getAnchorSelectedOS() || getDefaultSelectedOS();
18var opts = {
19  cuda: getPreferredCuda(default_selected_os),
20  os: default_selected_os,
21  pm: 'pip',
22  language: 'python',
23  ptbuild: 'stable',
24};
25
26var supportedCloudPlatforms = [
27  'aws',
28  'google-cloud',
29  'microsoft-azure',
30  'lightning-studios',
31];
32
33var os = $(".os > .option");
34var package = $(".package > .option");
35var language = $(".language > .option");
36var cuda = $(".cuda > .option");
37var ptbuild = $(".ptbuild > .option");
38
39os.on("click", function() {
40  selectedOption(os, this, "os");
41});
42package.on("click", function() {
43  selectedOption(package, this, "pm");
44});
45language.on("click", function() {
46  selectedOption(language, this, "language");
47});
48cuda.on("click", function() {
49  selectedOption(cuda, this, "cuda");
50});
51ptbuild.on("click", function() {
52  selectedOption(ptbuild, this, "ptbuild")
53});
54
55// Pre-select user's operating system
56$(function() {
57  var userOsOption = document.getElementById(opts.os);
58  var userCudaOption = document.getElementById(opts.cuda);
59  if (userOsOption) {
60    $(userOsOption).trigger("click");
61  }
62  if (userCudaOption) {
63    $(userCudaOption).trigger("click");
64  }
65});
66
67
68// determine os (mac, linux, windows) based on user's platform
69function getDefaultSelectedOS() {
70  var platform = navigator.platform.toLowerCase();
71  for (var [navPlatformSubstring, os] of supportedOperatingSystems.entries()) {
72    if (platform.indexOf(navPlatformSubstring) !== -1) {
73      return os;
74    }
75  }
76  // Just return something if user platform is not in our supported map
77  return supportedOperatingSystems.values().next().value;
78}
79
80// determine os based on location hash
81function getAnchorSelectedOS() {
82  var anchor = location.hash;
83  var ANCHOR_REGEX = /^#[^ ]+$/;
84  // Look for anchor in the href
85  if (!ANCHOR_REGEX.test(anchor)) {
86    return false;
87  }
88  // Look for anchor with OS in the first portion
89  var testOS = anchor.slice(1).split("-")[0];
90  for (var [navPlatformSubstring, os] of supportedOperatingSystems.entries()) {
91    if (testOS.indexOf(navPlatformSubstring) !== -1) {
92      return os;
93    }
94  }
95  return false;
96}
97
98// determine CUDA version based on OS
99function getPreferredCuda(os) {
100  // Only CPU builds are currently available for MacOS
101  if (os == 'macos') {
102    return 'accnone';
103  }
104  return 'cuda.x';
105}
106
107// Disable compute platform not supported on OS
108function disableUnsupportedPlatforms(os) {
109
110  if(opts.ptbuild == "preview")
111    archMap = version_map.nightly
112  else
113    archMap = version_map.release
114
115  for (const [arch_key, info] of archInfoMap) {
116    var elems = document.querySelectorAll('[id^="'+arch_key+'"]');
117    if (elems == null) {
118      console.log("Failed to find element for architecture " + arch_key);
119      return;
120    }
121    for (var i=0; i < elems.length;i++) {
122      var supported = info.platforms.has(os);
123      elems[i].style.textDecoration = supported ? "" : "line-through";
124
125      // Officially supported arch but not available
126      if(!archMap[elems[i].id]) {
127        elems[i].style.textDecoration =  "line-through";
128      }
129    }
130  }
131}
132
133// Change compute versions depending on build type
134function changeVersion(ptbuild) {
135
136  if(ptbuild == "preview")
137    archMap = version_map.nightly
138  else
139    archMap = version_map.release
140
141  for (const [arch_key, info] of archInfoMap) {
142    var elems = document.querySelectorAll('[id^="'+arch_key+'"]');
143    for (var i=0; i < elems.length;i++) {
144      if(archMap[elems[i].id]) {
145        elems[i].style.textDecoration = "";
146        elems[i].children[0].textContent = info.title + " " + archMap[elems[i].id][1]
147      } else {
148        elems[i].style.textDecoration = "line-through";
149      }
150    }
151  }
152  var stable_element = document.getElementById("stable");
153  stable_element.children[0].textContent = stable_version;
154}
155
156
157
158// Change accnone name depending on OS type
159function changeAccNoneName(osname) {
160  var accnone_element = document.getElementById("accnone");
161  if (accnone_element == null) {
162    console.log("Failed to find accnone element");
163    return;
164  }
165  if (osname == "macos") {
166    accnone_element.children[0].textContent = "Default";
167  } else {
168    accnone_element.children[0].textContent = "CPU";
169  }
170}
171
172function selectedOption(option, selection, category) {
173  $(option).removeClass("selected");
174  $(selection).addClass("selected");
175  opts[category] = selection.id;
176  if (category === "pm") {
177    var elements = document.getElementsByClassName("language")[0].children;
178    if (selection.id !== "libtorch" && elements["cplusplus"].classList.contains("selected")) {
179      $(elements["cplusplus"]).removeClass("selected");
180      $(elements["python"]).addClass("selected");
181      opts["language"] = "python";
182    } else if (selection.id == "libtorch") {
183      for (var i = 0; i < elements.length; i++) {
184        if (elements[i].id === "cplusplus") {
185          $(elements[i]).addClass("selected");
186          opts["language"] = "cplusplus";
187        } else {
188          $(elements[i]).removeClass("selected");
189        }
190      }
191    }
192  } else if (category === "language") {
193    var elements = document.getElementsByClassName("package")[0].children;
194    if (selection.id !== "cplusplus" && elements["libtorch"].classList.contains("selected")) {
195      $(elements["libtorch"]).removeClass("selected");
196      $(elements["pip"]).addClass("selected");
197      opts["pm"] = "pip";
198    } else if (selection.id == "cplusplus") {
199      for (var i = 0; i < elements.length; i++) {
200        if (elements[i].id === "libtorch") {
201          $(elements[i]).addClass("selected");
202          opts["pm"] = "libtorch";
203        } else {
204          $(elements[i]).removeClass("selected");
205        }
206      }
207    }
208  } else if (category == "ptbuild") {
209    changeVersion(opts.ptbuild);
210    //make sure unsupported platforms are disabled
211    disableUnsupportedPlatforms(opts.os);
212  }
213  commandMessage(buildMatcher());
214  if (category === "os") {
215    disableUnsupportedPlatforms(opts.os);
216    display(opts.os, 'installation', 'os');
217  }
218  changeAccNoneName(opts.os);
219}
220
221function display(selection, id, category) {
222  var container = document.getElementById(id);
223  // Check if there's a container to display the selection
224  if (container === null) {
225    return;
226  }
227  var elements = container.getElementsByClassName(category);
228  for (var i = 0; i < elements.length; i++) {
229    if (elements[i].classList.contains(selection)) {
230      $(elements[i]).addClass("selected");
231    } else {
232      $(elements[i]).removeClass("selected");
233    }
234  }
235}
236
237function buildMatcher() {
238  return (
239    opts.ptbuild.toLowerCase() +
240    "," +
241    opts.pm.toLowerCase() +
242    "," +
243    opts.os.toLowerCase() +
244    "," +
245    opts.cuda.toLowerCase() +
246    "," +
247    opts.language.toLowerCase()
248  );
249}
250
251// Cloud Partners sub-menu toggle listeners
252$("[data-toggle='cloud-dropdown']").on("click", function(e) {
253  if ($(this).hasClass("open")) {
254    $(this).removeClass("open");
255    // If you deselect a current drop-down item, don't display it's info any longer
256    display(null, 'cloud', 'platform');
257  } else {
258    $("[data-toggle='cloud-dropdown'].open").removeClass("open");
259    $(this).addClass("open");
260    var cls = $(this).find(".cloud-option-body")[0].className;
261    for (var i = 0; i < supportedCloudPlatforms.length; i++) {
262      if (cls.includes(supportedCloudPlatforms[i])) {
263        display(supportedCloudPlatforms[i], 'cloud', 'platform');
264      }
265    }
266  }
267});
268
269function commandMessage(key) {
270  var object = {"preview,pip,linux,accnone,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,linux,cuda.x,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu126", "preview,pip,linux,cuda.y,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu130", "preview,pip,linux,cuda.z,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu132", "preview,pip,linux,rocm5.x,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/rocm10.0", "preview,libtorch,linux,accnone,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-shared-with-deps-latest.zip</a>", "preview,libtorch,linux,cuda.x,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu126/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu126/libtorch-shared-with-deps-latest.zip</a>", "preview,libtorch,linux,cuda.y,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu130/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu130/libtorch-shared-with-deps-latest.zip</a>", "preview,libtorch,linux,cuda.z,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu132/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu132/libtorch-shared-with-deps-latest.zip</a>", "preview,libtorch,linux,rocm5.x,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/nightly/rocm10.0/libtorch-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/rocm10.0/libtorch-shared-with-deps-latest.zip</a>", "preview,pip,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package<br />pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,macos,accnone,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,libtorch,macos,accnone,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip</a>", "preview,libtorch,macos,cuda.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip</a>", "preview,libtorch,macos,cuda.y,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip</a>", "preview,libtorch,macos,cuda.z,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip</a>", "preview,libtorch,macos,rocm5.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-macos-arm64-latest.zip</a>", "preview,pip,windows,accnone,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cpu", "preview,pip,windows,cuda.x,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu126", "preview,pip,windows,cuda.y,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu130", "preview,pip,windows,cuda.z,python": "pip3 install --pre torch torchvision --index-url https://download.pytorch.org/whl/nightly/cu132", "preview,pip,windows,rocm5.x,python": "<b>NOTE:</b> ROCm is not available on Windows", "preview,libtorch,windows,accnone,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/nightly/cpu/libtorch-win-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cpu/libtorch-win-shared-with-deps-latest.zip</a>", "preview,libtorch,windows,cuda.x,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu126/libtorch-win-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu126/libtorch-win-shared-with-deps-latest.zip</a>", "preview,libtorch,windows,cuda.y,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu130/libtorch-win-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu130/libtorch-win-shared-with-deps-latest.zip</a>", "preview,libtorch,windows,cuda.z,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/nightly/cu132/libtorch-win-shared-with-deps-latest.zip'>https://download.pytorch.org/libtorch/nightly/cu132/libtorch-win-shared-with-deps-latest.zip</a>", "preview,libtorch,windows,rocm5.x,cplusplus": "<b>NOTE:</b> ROCm is not available on Windows", "stable,pip,linux,accnone,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cpu", "stable,pip,linux,cuda.x,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126", "stable,pip,linux,cuda.y,python": "pip3 install torch torchvision", "stable,pip,linux,cuda.z,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu132", "stable,pip,linux,rocm5.x,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/rocm7.14", "stable,libtorch,linux,accnone,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.14.0%2Bcpu.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-shared-with-deps-2.14.0%2Bcpu.zip</a>", "stable,libtorch,linux,cuda.x,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/cu126/libtorch-shared-with-deps-2.14.0%2Bcu126.zip'>https://download.pytorch.org/libtorch/cu126/libtorch-shared-with-deps-2.14.0%2Bcu126.zip</a>", "stable,libtorch,linux,cuda.y,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/cu130/libtorch-shared-with-deps-2.14.0%2Bcu130.zip'>https://download.pytorch.org/libtorch/cu130/libtorch-shared-with-deps-2.14.0%2Bcu130.zip</a>", "stable,libtorch,linux,cuda.z,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/cu132/libtorch-shared-with-deps-2.14.0%2Bcu132.zip'>https://download.pytorch.org/libtorch/cu132/libtorch-shared-with-deps-2.14.0%2Bcu132.zip</a>", "stable,libtorch,linux,rocm5.x,cplusplus": "Download here (cxx11 ABI):<br /><a href='https://download.pytorch.org/libtorch/rocm7.14/libtorch-shared-with-deps-2.14.0%2Brocm7.14.zip'>https://download.pytorch.org/libtorch/rocm7.14/libtorch-shared-with
270-deps-2.14.0%2Brocm7.14.zip</a>", "stable,pip,macos,cuda.x,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install torch torchvision", "stable,pip,macos,cuda.y,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install torch torchvision", "stable,pip,macos,cuda.z,python": "# CUDA is not available on MacOS, please use default package<br />pip3 install torch torchvision", "stable,pip,macos,rocm5.x,python": "# ROCm is not available on MacOS, please use default package<br />pip3 install torch torchvision", "stable,pip,macos,accnone,python": "pip3 install torch torchvision", "stable,libtorch,macos,accnone,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip</a>", "stable,libtorch,macos,cuda.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip</a>", "stable,libtorch,macos,cuda.y,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip</a>", "stable,libtorch,macos,cuda.z,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip</a>", "stable,libtorch,macos,rocm5.x,cplusplus": "Download arm64 libtorch here (ROCm and CUDA are not supported):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-macos-arm64-2.14.0.zip</a>", "stable,pip,windows,accnone,python": "pip3 install torch torchvision", "stable,pip,windows,cuda.x,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu126", "stable,pip,windows,cuda.y,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu130", "stable,pip,windows,cuda.z,python": "pip3 install torch torchvision --index-url https://download.pytorch.org/whl/cu132", "stable,pip,windows,rocm5.x,python": "<b>NOTE:</b> ROCm is not available on Windows", "stable,libtorch,windows,accnone,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.14.0%2Bcpu.zip'>https://download.pytorch.org/libtorch/cpu/libtorch-win-shared-with-deps-2.14.0%2Bcpu.zip</a>", "stable,libtorch,windows,cuda.x,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/cu126/libtorch-win-shared-with-deps-2.14.0%2Bcu126.zip'>https://download.pytorch.org/libtorch/cu126/libtorch-win-shared-with-deps-2.14.0%2Bcu126.zip</a>", "stable,libtorch,windows,cuda.y,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/cu130/libtorch-win-shared-with-deps-2.14.0%2Bcu130.zip'>https://download.pytorch.org/libtorch/cu130/libtorch-win-shared-with-deps-2.14.0%2Bcu130.zip</a>", "stable,libtorch,windows,cuda.z,cplusplus": "Download here (Release version):<br /><a href='https://download.pytorch.org/libtorch/cu132/libtorch-win-shared-with-deps-2.14.0%2Bcu132.zip'>https://download.pytorch.org/libtorch/cu132/libtorch-win-shared-with-deps-2.14.0%2Bcu132.zip</a>", "stable,libtorch,windows,rocm5.x,cplusplus": "<b>NOTE:</b> ROCm is not available on Windows"};
271
272  if (!object.hasOwnProperty(key)) {
273    $("#command").html(
274      "<pre> # Follow instructions at this URL: https://github.com/pytorch/pytorch#from-source </pre>"
275    );
276  } else if (key.indexOf("lts") == 0  && key.indexOf('rocm') < 0) {
277    $("#command").html("<pre>" + object[key] + "</pre>");
278  } else {
279    $("#command").html("<pre>" + object[key] + "</pre>");
280  }
281}
282
283// Set cuda version right away
284changeVersion("stable")
285

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.