<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by WilsonGo on Medium]]></title>
        <description><![CDATA[Stories by WilsonGo on Medium]]></description>
        <link>https://medium.com/@hqsiswiliam?source=rss-a11eddab428c------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*uoLREXrz1iLBAHXMSwCppQ.png</url>
            <title>Stories by WilsonGo on Medium</title>
            <link>https://medium.com/@hqsiswiliam?source=rss-a11eddab428c------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 28 Nov 2026 22:17:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@hqsiswiliam/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[One potential solution for frozen dist.init_process_group]]></title>
            <link>https://medium.com/@hqsiswiliam/one-potential-solution-for-frozen-dist-init-process-group-7b35b82048d5?source=rss-a11eddab428c------2</link>
            <guid isPermaLink="false">https://medium.com/p/7b35b82048d5</guid>
            <category><![CDATA[ddp]]></category>
            <category><![CDATA[torch]]></category>
            <category><![CDATA[dist]]></category>
            <category><![CDATA[distributed-training]]></category>
            <category><![CDATA[pytorch]]></category>
            <dc:creator><![CDATA[WilsonGo]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 12:48:19 GMT</pubDate>
            <atom:updated>2023-08-02T12:48:19.762Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mAMvf4LPzASSrQHOXKMAuQ.jpeg" /></figure><h3>Problem Statement</h3><p>During DDP initialization, I use a setup() function to initialize to the distribution as</p><pre>def setup(rank, world_size):<br>    os.environ[&#39;MASTER_ADDR&#39;] = &#39;localhost&#39;<br>    os.environ[&#39;MASTER_PORT&#39;] = &#39;29899&#39;<br>    # initialize the process group<br>    dist.init_process_group(&quot;nccl&quot;, init_method=&quot;env://&quot;,<br>                            rank=rank, world_size=world_size)</pre><p>And I start my program by</p><pre>python -m torch.distributed.launch --nproc_per_node=1 train.py</pre><p>Then I stucked at the dist.init_process_group method.</p><p>After tons of web searching, I tried installing Apex and different backend, but none are worked.</p><h3>Solution</h3><p>Then, I realized the last time I ran DDP program, which specified the port as argument outside the train.py. The form follows:</p><pre>python -m torch.distributed.launch --master_port=29899 --nproc_per_node=1 train.py</pre><p>After specifying the port, the os.environ can be actually moved from the setup() , so the setup() becomes:</p><pre>def setup(rank, world_size):<br>    # initialize the process group<br>    dist.init_process_group(&quot;nccl&quot;, init_method=&quot;env://&quot;,<br>                            rank=rank, world_size=world_size)</pre><p>You can check the MASETER_PORT and MASTER_ADDR by using os.getenv(&#39;MASTER_PORT&#39;)</p><p>The port should be automatically set by the outer augment</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7b35b82048d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Conquering the cudnn Issue in Your Conda Environment]]></title>
            <link>https://medium.com/@hqsiswiliam/conquering-the-cudnn-issue-in-your-conda-environment-f09ae75c83a2?source=rss-a11eddab428c------2</link>
            <guid isPermaLink="false">https://medium.com/p/f09ae75c83a2</guid>
            <category><![CDATA[anaconda]]></category>
            <category><![CDATA[cudnn]]></category>
            <category><![CDATA[conda-environment]]></category>
            <category><![CDATA[deep-learning-framework]]></category>
            <category><![CDATA[conda]]></category>
            <dc:creator><![CDATA[WilsonGo]]></dc:creator>
            <pubDate>Wed, 02 Aug 2023 01:38:10 GMT</pubDate>
            <atom:updated>2023-08-02T23:48:03.254Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YyJ4kAhx-LnXhIZxrpQg0Q.png" /></figure><h3><strong>Introduction:</strong></h3><p>Deep learning enthusiasts often face hurdles in their journey to cutting-edge AI solutions. One common obstacle is encountering the perplexing cudnn issue while running scripts. Fear not, as we present a step-by-step guide to triumph over this challenge and unleash the true potential of your deep learning projects.</p><h3><strong>The Cudnn Conundrum:</strong></h3><p>Imagine this: You’re immersed in running a profound deep learning script, and suddenly, an error disrupts your flow:</p><pre>Could not load library libcudnn_cnn_infer.so.8. Error: libnvrtc.so: cannot open shared object file: No such file or directory</pre><p>This seemingly insurmountable obstacle might leave you scratching your head, wondering where to find a solution. Fear not! We’ve got you covered.</p><h3><strong>WSL2 Solution:</strong></h3><p>Before digging into the following (that installs cudnn into conda), here is a simple solution for WSL2 environment:</p><p>First, check if the cuda path is alredy in your ldconfig</p><pre>ldconfig -p | grep cuda</pre><p>Then, add wsl path to LD_LIBRARY_PATH</p><pre>export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH</pre><h3><strong>Unraveling the Solution:</strong></h3><p>The answer lies in installing the Cudnn library under your conda environment. With this straightforward fix, you’ll be back on track to harnessing the immense power of your deep learning prowess.</p><h3><strong>Step-by-Step Solution:</strong></h3><p>Follow these simple steps to put an end to the cudnn issue and resume your journey towards AI excellence:</p><pre># Set environment name<br>CONDAENV=YourEnvName<br># Activate Envrionment<br>conda activate ${CONDAENV}<br># Install cudatoolkit, you can change the version by your preference<br>conda install -c &quot;nvidia/label/cuda-11.8.0&quot; cuda-toolkit<br># Install cudnn, you can change the version by your preference<br>python3 -m pip install nvidia-cudnn-cu11==8.5.0.96<br># Link up the cudnn into the LD_LIBRARY_PATH<br>mkdir -p $CONDA_PREFIX/envs/${CONDAENV}/etc/conda/activate.d<br>echo &#39;CUDNN_PATH=$(dirname $(python -c &quot;import nvidia.cudnn;print(nvidia.cudnn.__file__)&quot;))&#39; &gt;&gt; $CONDA_PREFIX/envs/${CONDAENV}/etc/conda/activate.d/env_vars.sh<br>echo &#39;export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$CONDA_PREFIX/lib/:$CUDNN_PATH/lib&#39; &gt;&gt; $CONDA_PREFIX/envs/${CONDAENV}/etc/conda/activate.d/env_vars.sh<br># Source the script if you want to use it immediately<br>source $CONDA_PREFIX/envs/${CONDAENV}/etc/conda/activate.d/env_vars.sh</pre><h3><strong>Universal Compatibility:</strong></h3><p>Our solution applies seamlessly to both <strong>Ubuntu </strong>and <strong>WSL</strong> environments. Now, you can break down the barriers that once held you back from unleashing your deep learning projects’ full potential.</p><h3><strong>Conclusion:</strong></h3><p>In conclusion, installing the Cudnn library under your conda environment is the key to overcoming the cudnn issue in deep learning scripts. With our simple and effective solution, you can break through barriers and unlock the full potential of your projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f09ae75c83a2" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Deploy rails project via capistrano simply in 3 minutes]]></title>
            <link>https://medium.com/@hqsiswiliam/deploy-rails-project-via-capistrano-simply-in-3-minutes-a31a0f4bec66?source=rss-a11eddab428c------2</link>
            <guid isPermaLink="false">https://medium.com/p/a31a0f4bec66</guid>
            <category><![CDATA[ruby-on-rails]]></category>
            <category><![CDATA[server-deployment]]></category>
            <category><![CDATA[capistrano]]></category>
            <dc:creator><![CDATA[WilsonGo]]></dc:creator>
            <pubDate>Thu, 18 Apr 2019 05:41:51 GMT</pubDate>
            <atom:updated>2019-04-18T05:57:27.112Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/900/1*jzKyPG7_F-XhcKaeAMewbg.png" /></figure><ul><li>First, we add related gems into Gemfile and run bundle install:</li></ul><pre>group :development do<br>gem &quot;capistrano&quot;, &quot;~&gt; 3.10&quot;, require: false<br>gem &quot;capistrano-rails&quot;, &quot;~&gt; 1.3&quot;, require: false<br>gem &#39;capistrano3-puma&#39;<br>gem &#39;capistrano-rvm&#39;<br>gem &#39;capistrano-dotenv-tasks&#39;, require: false<br>end</pre><ul><li>Then we run:</li></ul><pre>bundle exec cap install</pre><ul><li>Next we edit Capfile in project:</li></ul><pre>require &#39;capistrano/dotenv/tasks&#39;<br>require &quot;capistrano/setup&quot;<br>require &#39;capistrano/rvm&#39;<br>require &quot;capistrano/deploy&quot;<br>require &#39;capistrano/rails&#39;<br>require &quot;capistrano/scm/git&quot;<br>install_plugin Capistrano::SCM::Git<br>require &#39;capistrano/puma&#39;<br>install_plugin Capistrano::Puma # Default puma tasks<br>install_plugin Capistrano::Puma::Nginx # if you want to upload a nginx site template<br>Dir.glob(&quot;lib/capistrano/tasks/*.rake&quot;).each { |r| import r }</pre><ul><li>And we edit config/deploy.rb to satisfy our needs:</li></ul><pre>lock &#39;~&gt; 3.11.0&#39;</pre><pre>set :application, &#39;project-name&#39;<br>set :repo_url, &#39;git@git.github.com:username/repo.git&#39;<br>set :deploy_to, &#39;/path/to/be/deployed&#39;<br>set :rvm_ruby_version, &#39;2.5.3&#39;<br>set :rvm_custom_path, &#39;/usr/share/rvm/&#39;<br>set :puma_user, &#39;username&#39;<br>append :linked_dirs, &#39;log&#39;, &#39;tmp/pids&#39;, &#39;tmp/cache&#39;, &#39;tmp/sockets&#39;, &#39;vendor/bundle&#39;, &#39;.bundle&#39;, &#39;public/system&#39;, &#39;public/uploads&#39;, &#39;db&#39;<br>append :linked_files, &#39;config/secrets.yml&#39;<br># Default branch is :master<br># ask :branch, `git rev-parse --abbrev-ref HEAD`.chomp</pre><pre># Default deploy_to directory is /var/www/my_app_name<br># set :deploy_to, &quot;/var/www/my_app_name&quot;</pre><pre># Default value for :format is :airbrussh.<br># set :format, :airbrussh</pre><pre># You can configure the Airbrussh format using :format_options.<br># These are the defaults.<br># set :format_options, command_output: true, log_file: &quot;log/capistrano.log&quot;, color: :auto, truncate: :auto</pre><pre># Default value for :pty is false<br># set :pty, true</pre><pre># Default value for :linked_files is []<br># append :linked_files, &quot;config/database.yml&quot;</pre><pre># Default value for linked_dirs is []<br># append :linked_dirs, &quot;log&quot;, &quot;tmp/pids&quot;, &quot;tmp/cache&quot;, &quot;tmp/sockets&quot;, &quot;public/system&quot;</pre><pre># Default value for default_env is {}<br># set :default_env, { path: &quot;/opt/ruby/bin:$PATH&quot; }</pre><pre># Default value for local_user is ENV[&#39;USER&#39;]<br># set :local_user, -&gt; { `git config user.name`.chomp }</pre><pre># Default value for keep_releases is 5<br># set :keep_releases, 5</pre><pre># Uncomment the following to require manually verifying the host key before first deploy.<br># set :ssh_options, verify_host_key: :secure</pre><pre>#if you want to upload assets in public folders<br># after &#39;deploy:symlink:linked_dirs&#39;, &#39;upload_files:upload_3rd_party&#39;</pre><pre># namespace :upload_files do<br>#   desc &#39;Upload files&#39;<br>#   task :upload_3rd_party do<br>#     on roles(:all) do<br>#       upload! &#39;public/bootstrap&#39;, &quot;#{release_path}/public&quot;, recursive: true<br>#       upload! &#39;public/font&#39;, &quot;#{release_path}/public&quot;, recursive: true<br>#       upload! &#39;public/ielts-statics&#39;, &quot;#{release_path}/public&quot;, recursive: true<br>#       upload! &#39;public/images&#39;, &quot;#{release_path}/public&quot;, recursive: true<br>#     end<br>#   end<br># end</pre><ul><li>after that, we start to config config/deploy/production.rb to config destination server:</li></ul><pre># frozen_string_literal: true</pre><pre># server-based syntax<br># ======================<br># Defines a single server with a list of roles and multiple properties.<br># You can define all roles on a single server, or split them:<br>server &#39;serverip&#39;, user: &#39;serverusername&#39;, roles: %w[app db web]</pre><pre>set :rails_env, &#39;production&#39;<br># server &quot;example.com&quot;, user: &quot;deploy&quot;, roles: %w{app db web}, my_property: :my_value<br># server &quot;example.com&quot;, user: &quot;deploy&quot;, roles: %w{app web}, other_property: :other_value<br># server &quot;db.example.com&quot;, user: &quot;deploy&quot;, roles: %w{db}</pre><pre># role-based syntax<br># ==================</pre><pre># Defines a role with one or multiple servers. The primary server in each<br># group is considered to be the first unless any hosts have the primary<br># property set. Specify the username and a domain or IP for the server.<br># Don&#39;t use `:all`, it&#39;s a meta role.</pre><pre># role :app, %w{deploy@example.com}, my_property: :my_value<br># role :web, %w{user1@primary.com user2@additional.com}, other_property: :other_value<br># role :db,  %w{deploy@example.com}</pre><pre># Configuration<br># =============<br># You can set any configuration variable like in config/deploy.rb<br># These variables are then only loaded and set in this stage.<br># For available Capistrano configuration variables see the documentation page.<br># <a href="http://capistranorb.com/documentation/getting-started/configuration/">http://capistranorb.com/documentation/getting-started/configuration/</a><br># Feel free to add new variables to customise your setup.</pre><pre># Custom SSH Options<br># ==================<br># You may pass any option but keep in mind that net/ssh understands a<br># limited set of options, consult the Net::SSH documentation.<br># <a href="http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start">http://net-ssh.github.io/net-ssh/classes/Net/SSH.html#method-c-start</a><br>#<br># Global options<br># --------------<br>#  set :ssh_options, {<br>#    keys: %w(/home/rlisowski/.ssh/id_rsa),<br>#    forward_agent: false,<br>#    auth_methods: %w(password)<br>#  }<br>#<br># The server-based syntax can be used to override options:<br># ------------------------------------<br># server &quot;example.com&quot;,<br>#   user: &quot;user_name&quot;,<br>#   roles: %w{web app},<br>#   ssh_options: {<br>#     user: &quot;user_name&quot;, # overrides user setting above<br>#     keys: %w(/home/user_name/.ssh/id_rsa),<br>#     forward_agent: false,<br>#     auth_methods: %w(publickey password)<br>#     # password: &quot;please use keys&quot;<br>#   }</pre><ul><li>Finally, let’s hit:</li></ul><pre>cap production deploy</pre><ul><li>To deploy rails app to server</li><li>if you need to config nginx file in server you can run:</li></ul><pre>cap production puma:nginx_config</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a31a0f4bec66" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The way to solve CORS problems in nginx]]></title>
            <link>https://medium.com/@hqsiswiliam/the-way-to-solve-cors-problems-in-nginx-3c1ce3f3f820?source=rss-a11eddab428c------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c1ce3f3f820</guid>
            <category><![CDATA[cors]]></category>
            <category><![CDATA[nginx]]></category>
            <dc:creator><![CDATA[WilsonGo]]></dc:creator>
            <pubDate>Wed, 17 Apr 2019 02:29:59 GMT</pubDate>
            <atom:updated>2019-04-17T02:29:59.322Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*C3f1rNpJosTqj38b5ELQYQ.png" /></figure><p>In specified location (where CORS is needed) insert:</p><blockquote>if ($request_method = ‘OPTIONS’) {<br> add_header ‘Access-Control-Allow-Origin’ ‘*’;<br> add_header ‘Access-Control-Allow-Credentials’ ‘true’;<br> add_header ‘Access-Control-Allow-Methods’ ‘*’;<br> add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,token’;<br> add_header ‘Access-Control-Max-Age’ 1728000;<br> add_header ‘Content-Type’ ‘text/plain charset=UTF-8’;<br> add_header ‘Content-Length’ 0;<br> return 204;<br> }<br> if ($request_method = ‘GET’) {<br> add_header ‘Access-Control-Allow-Origin’ ‘*’;<br> add_header ‘Access-Control-Allow-Credentials’ ‘true’;<br> add_header ‘Access-Control-Allow-Methods’ ‘*’;<br> add_header ‘Access-Control-Allow-Headers’ ‘DNT,X-CustomHeader,Keep-Alive,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,token’;<br> add_header ‘Access-Control-Max-Age’ 1728000;<br> add_header ‘Content-Type’ ‘text/plain charset=UTF-8’;<br> }</blockquote><p>In above code block, adding headers to options type and return 204 is for browser to successfully make pre-request. Meanwhile, we add corresponding headers to GET request for truly solve CORS GET problem. The mechanism underneath it is about adding “Access-Control-Allow” headers to responses.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c1ce3f3f820" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>