<?xml version="1.0" encoding="utf-8"?><feed xmlns="http://www.w3.org/2005/Atom" ><generator uri="https://jekyllrb.com/" version="3.9.5">Jekyll</generator><link href="https://yxzh321.github.io/feed.xml" rel="self" type="application/atom+xml" /><link href="https://yxzh321.github.io/" rel="alternate" type="text/html" /><updated>2024-07-12T21:44:26+00:00</updated><id>https://yxzh321.github.io/feed.xml</id><title type="html">Yaxuan Zhang’s</title><subtitle>Homepage</subtitle><author><name>Yaxuan Zhang</name></author><entry><title type="html">Using GPU with Julia</title><link href="https://yxzh321.github.io/doc/use-GPU-with-julia/" rel="alternate" type="text/html" title="Using GPU with Julia" /><published>2024-07-12T00:00:00+00:00</published><updated>2024-07-12T00:00:00+00:00</updated><id>https://yxzh321.github.io/doc/use-GPU-with-julia</id><content type="html" xml:base="https://yxzh321.github.io/doc/use-GPU-with-julia/"><![CDATA[<p>I wanted to use Julia package <a href="https://cuda.juliagpu.org/stable/installation/overview/">CUDA.jl</a> on computing clusters. But when I precompile the pkg, I got:</p>

<figure class="highlight"><pre><code class="language-shell" data-lang="shell">Error: CUDA.jl could not find an appropriate CUDA runtime to use.
This can have several reasons:
<span class="k">*</span> you are using an unsupported platform: this version of CUDA.jl
  only supports Linux <span class="o">(</span>x86_64, aarch64, ppc64le<span class="o">)</span> and Windows <span class="o">(</span>x86_64<span class="o">)</span>,
  <span class="k">while </span>your platform was identified as <span class="s1">'something'</span><span class="p">;</span>
<span class="k">*</span> you precompiled CUDA.jl <span class="k">in </span>an environment where the CUDA driver
  was not available <span class="o">(</span>i.e., a container, or an HPC login node<span class="o">)</span><span class="nb">.</span>
  <span class="k">in </span>that <span class="k">case</span>, you need to specify which CUDA version to use
  by calling <span class="sb">`</span>CUDA.set_runtime_version!<span class="sb">`</span><span class="p">;</span>
<span class="k">*</span> you requested use of a <span class="nb">local </span>CUDA toolkit, but not all
  required components were discovered. try running with
  <span class="nv">JULIA_DEBUG</span><span class="o">=</span>all <span class="k">in </span>your environment <span class="k">for </span>more details.

For more details, refer to the CUDA.jl documentation at
https://cuda.juliagpu.org/stable/installation/overview/
@ CUDA /software/opt/el_9/x86_64/julia/1.10.0/local/share/julia/packages/CUDA/rXson/src/initialization.jl:82</code></pre></figure>

<p>So I searched for this issue and got what I want from <a href="https://discourse.julialang.org/t/cuda-could-not-find-an-appropiate-cuda-runtime-to-use/97201/3">here</a>.<sup id="fnref:ref1" role="doc-noteref"><a href="#fn:ref1" class="footnote" rel="footnote">1</a></sup></p>

<p>For the same case as mine, one should first check the CUDA version number of your device by running nvidia-smi in BASH and/or using nvcc –version. For me, I used the latter and got</p>

<figure class="highlight"><pre><code class="language-shell" data-lang="shell">nvcc: NVIDIA <span class="o">(</span>R<span class="o">)</span> Cuda compiler driver
Copyright <span class="o">(</span>c<span class="o">)</span> 2005-2022 NVIDIA Corporation
Built on Tue_May__3_18:49:52_PDT_2022
Cuda compilation tools, release 11.7, V11.7.64
Build cuda_11.7.r11.7/compiler.31294372_0</code></pre></figure>

<p>Then I run:</p>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="n">julia</span><span class="o">&gt;</span> <span class="k">using</span> <span class="n">CUDA</span><span class="x">;</span> <span class="n">CUDA</span><span class="o">.</span><span class="n">set_runtime_version!</span><span class="x">(</span><span class="n">v</span><span class="s">"11.7"</span><span class="x">)</span></code></pre></figure>

<p>I got the same error but with additional info at the end:</p>

<figure class="highlight"><pre><code class="language-shell" data-lang="shell">Info: Configure the active project to use CUDA 11.7<span class="p">;</span> please re-start Julia <span class="k">for </span>this to take effect.</code></pre></figure>

<p>At last, I restarted Julia and typed ‘using CUDA’ again. Then the pkg precompiled successfully.</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:ref1" role="doc-endnote">
      <p>https://discourse.julialang.org/t/cuda-could-not-find-an-appropiate-cuda-runtime-to-use/97201/3 <a href="#fnref:ref1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Yaxuan Zhang</name></author><category term="Doc" /><category term="documentation" /><category term="tutorial" /><summary type="html"><![CDATA[I wanted to use Julia package CUDA.jl on computing clusters. But when I precompile the pkg, I got: Error: CUDA.jl could not find an appropriate CUDA runtime to use. This can have several reasons: * you are using an unsupported platform: this version of CUDA.jl only supports Linux (x86_64, aarch64, ppc64le) and Windows (x86_64), while your platform was identified as 'something'; * you precompiled CUDA.jl in an environment where the CUDA driver was not available (i.e., a container, or an HPC login node). in that case, you need to specify which CUDA version to use by calling `CUDA.set_runtime_version!`; * you requested use of a local CUDA toolkit, but not all required components were discovered. try running with JULIA_DEBUG=all in your environment for more details.]]></summary></entry><entry><title type="html">Solve ‘git push Permission denied (publickey)’</title><link href="https://yxzh321.github.io/doc/git-push-permission-denied/" rel="alternate" type="text/html" title="Solve ‘git push Permission denied (publickey)’" /><published>2024-07-02T00:00:00+00:00</published><updated>2024-07-02T00:00:00+00:00</updated><id>https://yxzh321.github.io/doc/git-push-permission-denied</id><content type="html" xml:base="https://yxzh321.github.io/doc/git-push-permission-denied/"><![CDATA[<p>It has been more than a year since I last updated GitHub. When I pushed changes to remote repo, I got error:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">git push -u origin master
Permission denied (publickey).
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.</span></code></pre></figure>

<p>and after some time, I found that it was because the SSH key had expired.</p>

<p>The solution is as follows if you already set SSH key in your device.<sup id="fnref:sol1" role="doc-noteref"><a href="#fn:sol1" class="footnote" rel="footnote">1</a></sup> Run in command line(git bash window):</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="gp">ls -al ~/.ssh #</span><span class="w"> </span>check <span class="k">if </span>you <span class="nb">set </span>SSH key</code></pre></figure>

<p>which should shows several files including <em>id_rsa</em> and <em>id_rsa.pub</em>. Then run:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">cat ~/.ssh/id_rsa.pub</span></code></pre></figure>

<p>copy the contents starting from <em>ssh-rsa</em> and paste it into your GitHub SSH keys setting.</p>

<p>If both your device and GitHub account have the SSH key but your permissioin was denied, then try the solution below:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">ssh-agent bash
ssh-add ~/.ssh/id_rsa</span></code></pre></figure>

<p>which might work.<sup id="fnref:sol2" role="doc-noteref"><a href="#fn:sol2" class="footnote" rel="footnote">2</a></sup></p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:sol1" role="doc-endnote">
      <p>https://www.sysadm.cc/index.php/webxuexi/978-github-ssh-key-expired-dont-worry-you-can-do-like-this (in Chinese) <a href="#fnref:sol1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:sol2" role="doc-endnote">
      <p>https://blog.csdn.net/Leo_Franklin/article/details/108858285 (in Chinese) <a href="#fnref:sol2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Yaxuan Zhang</name></author><category term="Doc" /><category term="documentation" /><category term="tutorial" /><summary type="html"><![CDATA[It has been more than a year since I last updated GitHub. When I pushed changes to remote repo, I got error: git push -u origin master Permission denied (publickey). fatal: Could not read from remote repository.]]></summary></entry><entry><title type="html">Using Julia on computing clusters</title><link href="https://yxzh321.github.io/doc/use-julia-on-cluster/" rel="alternate" type="text/html" title="Using Julia on computing clusters" /><published>2024-07-02T00:00:00+00:00</published><updated>2024-07-02T00:00:00+00:00</updated><id>https://yxzh321.github.io/doc/use-julia-on-cluster</id><content type="html" xml:base="https://yxzh321.github.io/doc/use-julia-on-cluster/"><![CDATA[<p>I wanted to use Julia on computing clusters with Jupyterhub at LMU. So I first checked if Julia is installed using:</p>

<figure class="highlight"><pre><code class="language-shell" data-lang="shell">pip show julia</code></pre></figure>

<p>which gave me the info about the installed Julia. But when I run:</p>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="n">julia</span></code></pre></figure>

<p>This returned:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">-bash: julia: command not found</span></code></pre></figure>

<p>and didn’t activate Julia. So I searched for this issue and got what I want from the website <a href="https://researchcomputing.princeton.edu/support/knowledge-base/julia">here</a>.<sup id="fnref:ref4" role="doc-noteref"><a href="#fn:ref4" class="footnote" rel="footnote">1</a></sup></p>

<p>One should use the commands below:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="go">module avail julia</span></code></pre></figure>

<p>which will show available Julia versions with their path. Then run:</p>

<figure class="highlight"><pre><code class="language-console" data-lang="console"><span class="gp">module load julia/1.x.x #</span><span class="w"> </span>version you want
<span class="gp">julia #</span><span class="w"> </span><span class="nb">type </span>julia</code></pre></figure>

<p>will start the Julia interactive session.</p>

<h2 id="install-julia-kernel-for-jupyternotebook">Install Julia kernel for JupyterNotebook</h2>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="n">julia</span><span class="o">&gt;</span> <span class="c"># start package manager by pressing ] key</span>
<span class="x">(</span><span class="nd">@v1.10</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">add</span> <span class="n">IJulia</span>
<span class="x">(</span><span class="nd">@v1.10</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="c"># leave package manager by pressing backspace/delete</span>
<span class="n">julia</span><span class="o">&gt;</span> <span class="k">using</span> <span class="n">IJulia</span>
<span class="n">julia</span><span class="o">&gt;</span> <span class="n">installkernel</span><span class="x">(</span><span class="s">"Julia"</span><span class="x">)</span></code></pre></figure>

<h2 id="work-with-environment">Work with Environment<sup id="fnref:ref1" role="doc-noteref"><a href="#fn:ref1" class="footnote" rel="footnote">2</a></sup></h2>

<p>This is similar to creating python virtualenv which is necessary for working with your own projects and environments on clusters.</p>

<p>When you first creat a project/env:</p>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="x">(</span><span class="nd">@v1.10</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">activate</span> <span class="o">&lt;</span><span class="n">YourProject</span><span class="o">&gt;</span>
<span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">st</span>
    <span class="n">Status</span> <span class="sb">`~/YourProject/Project.toml`</span> <span class="x">(</span><span class="n">empty</span> <span class="n">project</span><span class="x">)</span>
<span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">add</span> <span class="n">Plots</span> <span class="c"># add pkgs you want</span>
<span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">activate</span>  <span class="c"># leave the environment, then you go back to the default environment</span>
<span class="x">(</span><span class="nd">@v1.10</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span></code></pre></figure>

<p>When you already have the project/env<sup id="fnref:ref2" role="doc-noteref"><a href="#fn:ref2" class="footnote" rel="footnote">3</a></sup>:</p>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="n">cd</span> <span class="o">&lt;</span><span class="n">YourPathToYourProject</span><span class="o">&gt;/&lt;</span><span class="n">YourProject</span><span class="o">&gt;</span>
<span class="n">julia</span> <span class="o">--</span><span class="n">project</span><span class="o">=.</span>
<span class="n">julia</span><span class="o">&gt;</span> <span class="c"># press ]</span>
<span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span></code></pre></figure>

<p>or:</p>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="n">julia</span>
<span class="n">julia</span><span class="o">&gt;</span> <span class="c"># press ;</span>
<span class="n">shell</span><span class="o">&gt;</span> <span class="n">cd</span> <span class="o">&lt;</span><span class="n">YourPathToYourProject</span><span class="o">&gt;/&lt;</span><span class="n">YourProject</span><span class="o">&gt;</span>
<span class="n">shell</span><span class="o">&gt;</span> <span class="c"># press backspace and then press ]</span>
<span class="x">(</span><span class="nd">@v1.10</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span> <span class="n">activate</span> <span class="o">.</span>
<span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span></code></pre></figure>

<h2 id="add-an-additional-julia-kernel">Add an additional Julia kernel<sup id="fnref:ref3" role="doc-noteref"><a href="#fn:ref3" class="footnote" rel="footnote">4</a></sup></h2>

<figure class="highlight"><pre><code class="language-julia" data-lang="julia"><span class="x">(</span><span class="n">YourProject</span><span class="x">)</span> <span class="n">pkg</span><span class="o">&gt;</span>
<span class="n">julia</span><span class="o">&gt;</span> <span class="n">IJulia</span><span class="o">.</span><span class="n">installkernel</span><span class="x">(</span><span class="s">"Julia YourProjectEnv"</span><span class="x">,</span> <span class="s">"--project=</span><span class="si">$</span><span class="s">(Base.active_project())"</span><span class="x">)</span></code></pre></figure>

<p>The Launcher now has a new icon for starting a new jupyter notebook with “Julia YourProjectEnv”.</p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:ref4" role="doc-endnote">
      <p>https://researchcomputing.princeton.edu/support/knowledge-base/julia <a href="#fnref:ref4" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:ref1" role="doc-endnote">
      <p>https://pkgdocs.julialang.org/v1/environments/ <a href="#fnref:ref1" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:ref2" role="doc-endnote">
      <p>https://towardsdatascience.com/how-to-setup-project-environments-in-julia-ec8ae73afe9c <a href="#fnref:ref2" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
    <li id="fn:ref3" role="doc-endnote">
      <p>https://julialang.github.io/IJulia.jl/stable/manual/usage/ <a href="#fnref:ref3" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Yaxuan Zhang</name></author><category term="Doc" /><category term="documentation" /><category term="tutorial" /><summary type="html"><![CDATA[I wanted to use Julia on computing clusters with Jupyterhub at LMU. So I first checked if Julia is installed using: pip show julia which gave me the info about the installed Julia. But when I run: julia This returned: -bash: julia: command not found]]></summary></entry><entry><title type="html">Theories and Monte Carlo Simulation of Nematic Liquid Crystals</title><link href="https://yxzh321.github.io/projects/welcome-to-jekyll/" rel="alternate" type="text/html" title="Theories and Monte Carlo Simulation of Nematic Liquid Crystals" /><published>2022-07-23T00:00:00+00:00</published><updated>2022-07-23T00:00:00+00:00</updated><id>https://yxzh321.github.io/projects/welcome-to-jekyll</id><content type="html" xml:base="https://yxzh321.github.io/projects/welcome-to-jekyll/"><![CDATA[<p>This is a brief summary of a research project for the course <em>Thermodynamics</em> <em>and</em> <em>Statistical</em> <em>Mechanics</em> this year (2022)@School of Physics, Nankai University, China.</p>

<p>The project was a group work while I was involved in most parts of theoretical work and completed the whole <a href="https://github.com/yxzh321">simulation</a> .<sup id="fnref:simulation" role="doc-noteref"><a href="#fn:simulation" class="footnote" rel="footnote">1</a></sup></p>

<p><strong><em>To</em> <em>be</em> <em>continued</em>…</strong></p>

<div class="footnotes" role="doc-endnotes">
  <ol>
    <li id="fn:simulation" role="doc-endnote">
      <p>Code is available on my github page. <a href="#fnref:simulation" class="reversefootnote" role="doc-backlink">&#8617;</a></p>
    </li>
  </ol>
</div>]]></content><author><name>Yaxuan Zhang</name></author><category term="Projects" /><category term="update" /><category term="Monte Carlo Simulation" /><summary type="html"><![CDATA[This is a brief summary of a research project for the course Thermodynamics and Statistical Mechanics this year (2022)@School of Physics, Nankai University, China.]]></summary></entry></feed>