<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>I&#039;m a Bit</title>
	<atom:link href="https://www.imabit.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.imabit.com</link>
	<description>a Software Development Company</description>
	<lastBuildDate>Sun, 10 Feb 2019 20:09:06 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	

<image>
	<url>https://www.imabit.com/wp-content/uploads/2016/12/Half_Life_2_logo_by_Zeptozephyr-150x150.jpg</url>
	<title>I&#039;m a Bit</title>
	<link>https://www.imabit.com</link>
	<width>32</width>
	<height>32</height>
</image> 
	<item>
		<title>Compressing web server images</title>
		<link>https://www.imabit.com/2019/02/compressing-web-server-images/</link>
					<comments>https://www.imabit.com/2019/02/compressing-web-server-images/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Sun, 10 Feb 2019 20:03:11 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=594</guid>

					<description><![CDATA[Versión en español de esta publicación. It may be the case that you have a web server running and have a very big images (size and resolution) which are causing some problems in web pages like: Slow down of web page loading Images use a lot more hard disk space Bandwidth consumption grows Bad user experience&#8230;&#160;<a href="https://www.imabit.com/2019/02/compressing-web-server-images/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Compressing web server images</span></a>]]></description>
										<content:encoded><![CDATA[
<p><a href="https://www.hasdid.com/2019/02/optimizando-imagenes-de-directorios-de-una-pagina-web/" target="_blank" rel="noreferrer noopener" aria-label=" (opens in a new tab)">Versión en español de esta publicación. </a><br>It may be the case that you have a web server running and have a very big images (size and resolution) which are causing some problems in web pages like:</p>



<ul><li>Slow down of web page loading</li><li>Images use a lot more hard disk space</li><li>Bandwidth consumption grows</li><li>Bad user experience when visiting your site</li></ul>



<span id="more-594"></span>



<p>One blocker to compress images is that you can have lots of them in your site and going one by one to check their properties is simply not an option. In order to find a way around, we can use a bash script and a couple of nice linux libraries, <a href="https://packages.debian.org/stretch/imagemagick">imagemagick</a> and <a href="https://packages.debian.org/stretch/jpegoptim">jpegoptim</a>. The first library is used to scale the image to a specific width and height, the second one is used to add compression to the images and reduce the size</p>



<p>In order to install this libraries in the form of linux packages we can use this command in a debian like distribution</p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
sudo apt-get install imagemagick jpegoptim
</pre></div>


<p>Next, we show the bash script with the image optimization function that was created <br></p>


<div class="wp-block-syntaxhighlighter-code "><pre class="brush: bash; title: ; notranslate">
function optimize_web_images() {   
    declare -a search_dirs=(
        &quot;/var/www/mypage.com/images&quot; 
        &quot;/var/www/anotherpage.com/images&quot;
    )

    counter=1
    ## now loop through the dirs array
    for dir in &quot;${search_dirs&#91;@]}&quot;
    do
        echo &quot;Processing folder: ${dir} ..&quot;;
        find &quot;$dir&quot; -type f -exec file --mime-type {}  \; | awk '{if ($NF == &quot;image/jpeg&quot;) print $0 }' | while read f
        do
            local image_file=&quot;${f::-12}&quot;;
            local image_width=$(identify -format '%w' &quot;${image_file}&quot;);
            local max_width=&quot;1024&quot;;
            local max_optim=&quot;80&quot;;

            if &#91;&#91; &quot;${image_width}&quot; -gt &quot;${max_width}&quot; ]]; then
                echo &quot;Optimizing image ${image_file} .. old width: ${image_width}px, new width: ${max_width}px&quot;;
                convert &quot;${image_file}&quot; -resize &quot;${max_width}&quot;\&gt; &quot;${image_file}&quot;;
                jpegoptim --strip-all -q --max=&quot;${max_optim}&quot; &quot;${image_file}&quot;;
            fi
            
            # if processed images are 500, print progress
            if ! (( $counter % 500 )) ; then
                echo &quot;Processed $counter images ..&quot;
            fi

            # count processed images
            ((counter++))
        done
    done
}
</pre></div>


<p>Basically what this function does is to search for all image files recursively in a certain directory of a list that is passed as a parameter. To determine the file is actually an image we query for the file mime-type, this in order to avoid problems with the file extension in case of using approaches like using globs (&#8216;*.jpg&#8217;)</p>



<p>Once the images are found we proceed to determine if the image is a candidate of optimization by taking a look at the image dimension, for this we use the identify command of the imagemagick package. In case the image is actually a candidate for optimization we first use the convert command of the same library in order to scale the image to the desired size and then we use the jpegoptim command to compress the resulting image</p>



<p>In this way we optimize a list of images in a web server in an automated way that can be executed periodically in order to have reduced images and faster web page loads. Of course this script is just an example of the things we can do and it fits well with our use case, feel free to modify it to your needs and we hope is helpful to you.</p>



<p>Cheers! <br>-Yohan<br></p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2019/02/compressing-web-server-images/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Installing Nvidia Drivers and CUDA 9.1 in Debian Stretch</title>
		<link>https://www.imabit.com/2018/06/installing-nvidia-drivers-and-cuda-9-1-in-debian-stretch/</link>
					<comments>https://www.imabit.com/2018/06/installing-nvidia-drivers-and-cuda-9-1-in-debian-stretch/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Thu, 14 Jun 2018 05:01:53 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=563</guid>

					<description><![CDATA[Versión en español de esta publicación. This post explains how to install CUDA 9.1 Production Release on a Debian Stretch system. The first thing to do is to download the driver from the official Nvidia website and select the model of the video card you have. In my case, I have a server with 2&#8230;&#160;<a href="https://www.imabit.com/2018/06/installing-nvidia-drivers-and-cuda-9-1-in-debian-stretch/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Installing Nvidia Drivers and CUDA 9.1 in Debian Stretch</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2018/02/instalando-drivers-de-nvidia-y-cuda-9-1-en-debian-stretch/" target="_blank">Versión en español de esta publicación.</a><br />
This post explains how to install CUDA 9.1 Production Release on a Debian Stretch system. The first thing to do is to download the driver from the official Nvidia website and select the model of the video card you have. In my case, I have a server with 2 video cards, the first is a GeForce GTX660 and the second is a GeForce GTX650. If you are not sure which version of the driver should be installed, this information can be verified in the following link.<br />
<span id="more-563"></span></p>
<p><a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a></p>
<p>The latest version of the driver available in the case of my video cards is 390.25 and is available in the following link <a href="http://us.download.nvidia.com/XFree86/Linux-x86_64/390.25/NVIDIA-Linux-x86_64-390.25.run" target="_blank">http://us.download.nvidia.com/XFree86/Linux-x86_64/390.25/NVIDIA-Linux-x86_64-390.25.run</a>, the most desirable thing is to make sure to download the latest version of the driver available for your video card.</p>
<p>Also, it is necessary to download the CUDA Toolkit 9.1 from the Nvidia page located in the following link <a href="https://developer.nvidia.com/cuda-downloads?target_os=Linux&#038;target_arch=x86_64&#038;target_distro=Ubuntu&#038;target_version=1704&#038;target_type=runfilelocal" target="_blank">https://developer.nvidia.com/cuda-downloads?target_os=Linux&#038;target_arch=x86_64&#038;target_distro=Ubuntu&#038;target_version=1704&#038;target_type=runfilelocal</a>. The toolkit installation file that is needed is the <strong>RUN</strong> version for Ubuntu, the file name is: <em>cuda_9.1.85_387.26_linux.run</em>.</p>
<p>Now we proceed to verify the requirements to install CUDA. First of all you need to confirm that you have a device that supports GPUs.</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify we have a cuda capable gpu
lspci | grep -i nvidia
</pre>
<p>The previous instruction should yield results, otherwise, you should check the status of the video card. Then, we proceed to check our version of Linux</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# Linux version
uname -m &amp;&amp; cat /etc/*release
</pre>
<p>What tells us that we have Debian Stretch and is the version that is being used and supported for this post</p>
<pre class="brush: plain; title: ; notranslate">
x86_64
PRETTY_NAME=&quot;Debian GNU/Linux 9 (stretch)&quot;
NAME=&quot;Debian GNU/Linux&quot;
VERSION_ID=&quot;9&quot;
VERSION=&quot;9 (stretch)&quot;
ID=debian
HOME_URL=&quot;https://www.debian.org/&quot;
SUPPORT_URL=&quot;https://www.debian.org/support&quot;
BUG_REPORT_URL=&quot;https://bugs.debian.org/&quot;
</pre>
<p>Now you need to check that you have a valid GCC compiler</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify gcc version 
gcc --version
</pre>
<p>If you do not have a valid GCC compiler you can install it with the following command</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# gcc install
sudo apt-get install build-essential
</pre>
<p>Before proceeding with the installation process you need to uninstall any version of CUDA that has been previously installed, if this is the first time you install CUDA you can skip this step. To uninstall previous versions of CUDA the following command is used</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda uninstall
sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl
</pre>
<p>Where X and Y is the CUDA version. If you are updating the Nvidia driver you do not need to do anything since the installer removes the previous drivers automatically. If you want to uninstall the CUDA driver, you can do it with the following command.</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda driver uninstall
sudo /usr/bin/nvidia-uninstall
</pre>
<p>It is likely that you will need to uninstall nvidia packages if they have been installed through the repository. For this it could be sufficient to execute the following command</p>
<pre class="brush: bash; title: ; notranslate">
sudo apt-get remove 'nvidia*'
</pre>
<p>Once the previous steps have been completed and since the necessary files for the installation are available, we proceed to disable the nouveau driver, which is the default driver that comes with the Debian versions. In order to accomplish this a new file needs to be created</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# edit debian driver configuration file
vim /etc/modprobe.d/disable-nouveau.conf 
</pre>
<p>And we add the following lines</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# blacklist defualt driver
blacklist nouveau
options nouveau modeset=0
</pre>
<p>Note: to verify the nouveau driver is running or not, the following command needs to be executed and in the case the command shows results that means that you have the nouveau driver running in the system</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify driver
lsmod | grep nouveau
</pre>
<p>After having created the file to block the default driver, we proceed to restart the system in <em>default</em> mode. Once restarted we will notice that the resolution has dropped quality, this means that the default nouveau driver was not loaded, now we will proceed to install the linux headers from our repository in order to compile the Nvidia driver, we do this through the next command.</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# dependencies
sudo apt-get install linux-headers-$(uname -r)
</pre>
<p>After installing these packages we proceed to remove the nouveau driver completely from our system with the following command</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# remove
apt-get remove --purge xserver-xorg-video-nouveau
</pre>
<p>Once the driver is removed, the system is restarted in <strong>recovery</strong> mode. Once rebooted and in the console, we will proceed with the driver installation process. First, you need to know with what version of the compiler the kernel was compiled, this is because the system needs to compile the Nvidia driver. If you do not know the version of the compiler or the kernel, you can know that information by using the following command</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# find curr gcc version
cat /proc/version
</pre>
<p>Once you know the correct version of the compiler, you need to set it up by means of an export in the following way</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# set gcc version
export CC=gcc-4.8
</pre>
<p>Now you can proceed with the driver installation, navigate to the driver download directory and run</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute driver install
sudo sh NVIDIA-Linux-x86_64-390.25.run
</pre>
<p>Once the installation is finished, we proceed to restart our system. Note that the resolution went up in quality which means that our Nvidia drivers were installed correctly. Now, we proceed with the installation of the Cuda toolkit in the following way</p>
<p><b>cuda_9_1_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute toolkit install
sudo sh cuda_9.1.85_387.26_linux.run
</pre>
<p>When asked, you need to select the option of <strong>not</strong> install the Nvidia driver since it has already been installed previously, and select the default installation directory for the examples. The last thing you have to do is to compile these examples and execute them, this is done by navigating to the installation directory of the examples using the <strong>make</strong> command. Usually the default directory of the examples lies in our home directory so the following command should do the trick</p>
<pre class="brush: bash; title: ; notranslate">
cd ~/NVIDIA_CUDA-9.1_Samples
make
</pre>
<p>And that is pretty much it!</p>
<p><strong>Reference Links</strong></p>
<p>Cuda Installation Guide<br />
<a href="https://developer.download.nvidia.com/compute/cuda/9.1/Prod/docs/sidebar/CUDA_Installation_Guide_Linux.pdf" rel="noopener" target="_blank">https://developer.download.nvidia.com/compute/cuda/9.1/Prod/docs/sidebar/CUDA_Installation_Guide_Linux.pdf</a><br />
CUDA Quick Start Guide<br />
<a href="http://developer.download.nvidia.com/compute/cuda/9.1/Prod/docs/sidebar/CUDA_Quick_Start_Guide.pdf" rel="noopener" target="_blank">http://developer.download.nvidia.com/compute/cuda/9.1/Prod/docs/sidebar/CUDA_Quick_Start_Guide.pdf</a><br />
CUDA Toolkit Official Documentation<br />
<a href="http://docs.nvidia.com/cuda/index.html" rel="noopener" target="_blank">http://docs.nvidia.com/cuda/index.html</a><br />
CUDA Download Page<br />
<a href="https://developer.nvidia.com/cuda-downloads" title="https://developer.nvidia.com/cuda-downloads" target="_blank">https://developer.nvidia.com/cuda-downloads</a><br />
Nvidia Driver Download Page<br />
<a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" title="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a><br />
CUDA 9.1 Performance Presentation<br />
<a href="http://on-demand.gputechconf.com/gtc/2017/video/s7495-jain-optimizing-application-performance-cuda-profiling.mp4" rel="noopener" target="_blank">http://on-demand.gputechconf.com/gtc/2017/video/s7495-jain-optimizing-application-performance-cuda-profiling.mp4</a><br />
CUDA Toolkit Release Notes<br />
<a href="https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html" rel="noopener" target="_blank">https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html</a></p>
<p>Enjoy! <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2018/06/installing-nvidia-drivers-and-cuda-9-1-in-debian-stretch/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		<enclosure url="http://on-demand.gputechconf.com/gtc/2017/video/s7495-jain-optimizing-application-performance-cuda-profiling.mp4" length="1838484363" type="video/mp4" />

			</item>
		<item>
		<title>Doctoral Thesis Structure Proposal</title>
		<link>https://www.imabit.com/2018/06/doctoral-thesis-structure-proposal/</link>
					<comments>https://www.imabit.com/2018/06/doctoral-thesis-structure-proposal/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Tue, 12 Jun 2018 23:19:22 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=543</guid>

					<description><![CDATA[Versión en español de esta publicación. Some time ago I wanted to write this post and I didn&#8217;t had the opportunity. In general, one would like to have as much information as possible to be able to structure your thesis document in the desired way. This has not been my case, and in an attempt&#8230;&#160;<a href="https://www.imabit.com/2018/06/doctoral-thesis-structure-proposal/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Doctoral Thesis Structure Proposal</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2017/08/mi-propuesta-de-estructura-de-una-tesis-doctoral/" target="_blank">Versión en español de esta publicación.</a><br />
Some time ago I wanted to write this post and I didn&#8217;t had the opportunity. In general, one would like to have as much information as possible to be able to structure your thesis document in the desired way. This has not been my case, and in an attempt to make things easier for someone else in the same situation, I have decided to make this writing. Learning <img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> to write all kinds of documents is a true delight! However, its not easy, here I intend to reflect some tips that have been useful for me to write my doctoral thesis document that eventually became a book and can be found in the following <a href="https://www.amazon.com/Simulaci%C3%B3n-Computacional-Campo-Electromagn%C3%A9tico-Nanoestructuras/dp/3639811674" target="_blank">url</a>.<br />
<span id="more-543"></span></p>
<h2>Practices</h2>
<p>Probably these tips are not for all people. Remember that my passion and main occupation is <em>to program</em>. And as a programmer I have in mind some concepts that I can not easily get rid of. When using <img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> you are practically programming, the difference is that when you compile, instead of watching a program, page, component, app, robot or whatever you are creating, you will see a <em>beatiful document</em> in pdf format. Although in reality it can be another format, but at the end of the day in this article I refer to a document and specifically, a pdf.</p>
<p>When programming a system, I always like and as much as possible have organization in the code. I like to separate the pieces of the program into easily manageable logical entities. I applied this practices to the writing of my doctoral document. And, similar to any programming language, <img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> allows you to modulate files of multiple formats in the document itself, without the need to have everything embedded in a monolithic file. When talking about files I mean multiple formats, in my thesis, I have separated text content files in multiple levels, image files, code files, bibliography files, among which I can think for the moment.</p>
<h2>Thesis Structure</h2>
<p>I have always been used to reading books and a large part of the decisions made to write a thesis is based precisely on the format of the books I have read, taking into account the ease of reading, the quality of the content, the ease of finding conclusions and references about something quickly, and in general, the experience of the end user. Probably the suggested structure is more like a book than a thesis document.</p>
<ul>
<li><strong>Cover</strong><br />
For the cover there is not much to say, there is no standard way to do it. Therefore, it becomes somewhat an art because of the design side. The only thing to emphasize is the fulfillment of including all the information required by the university.</br></br>
</li>
<li><strong>Dedication</strong><br />
From my point of view, this is a brief but indispensable part of the document. Styles vary but more than seeking a recommendation is to find the inspiration that dictates the right words that reflect these feelings.</br></br>
</li>
<li><strong>Abstract</strong><br />
Although this section is not strictly necessary as a rule, I have always liked to know what a document is about, especially when it is of a considerable size. In any case, some authors caution against extending this section too much because of the possibility of duplicating content or discouraging the reader. In my opinion and as it is done in science articles, it is always good to know what a document is about and its objectives before immersing yourself in its reading.</br></br>
</li>
<li><strong>Preface</strong><br />
It should be mentioned that this section is not strictly necessary but it is my pleasure to include it in the structure.</br></br>
</li>
<li><strong>Acknowledgment</strong><br />
Space for acknowledgments.</br></br>
</li>
<li><strong>Table of Contents</strong><br />
The typical table that shows the content of the thesis.</br></br>
</li>
<li><strong>List of figures</strong><br />
The common list of figures.</br></br>
</li>
<li><strong>Code Listings</strong><br />
I have decided to include code listings for readability and ease.</br></br>
</li>
<li><strong>Chapters</strong><br />
One of the important decisions of the structure of a thesis is the design in the writing of chapters. In recent dates, I have seen some theses and books that produce chapters as independent units in terms of bibliography, this has always been to my liking since it is easier to find the references that belong to the chapter that is being read and not have to go to the end of the book to locate a reference. In my case, I have gone further and have decided to include conclusions for each chapter since I consider that this content should be included in the same section of the content.</br></br>
</li>
<li><strong>Conclusions, Results and Future Work</strong><br />
It was decided that both the conclusions and references be global, unlike the conclusions and references of each chapter. With this we have the opportunity to express in a global context the results and conclusions reached.</br></br>
</li>
<li><strong>Appendices</strong><br />
List of Appendices.</br></br>
</li>
</ul>
<h2>Directories</h2>
<p>Since it is intended to have all the content of the thesis separated, it has been decided to make a logical separation according to the defined structure, that is, each section will have its separate directory and each directory will contain a child directory for the figures and another one for the code files. Virtually all files will be separate and independent and only a document with this embedded information will be generated when the solution is compiled.</p>
<p><img loading="lazy" src="https://www.imabit.com/wp-content/uploads/2018/06/structure1.jpg" alt="" width="450" height="444" class="alignnone size-medium wp-image-4027" /></p>
<p><img loading="lazy" src="https://www.imabit.com/wp-content/uploads/2018/06/structure2.jpg" alt="" width="450" height="418" class="alignnone size-medium wp-image-4028" /></p>
<h2>LaTeX</h2>
<p>Once having the desired structure available. We proceed to capture the code <img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> to build our document. The main code file is listed below.</p>
<p><strong>thesis.tex</strong></p>
<pre class="brush: xml; title: ; notranslate">
\documentclass[12pt,letterpaper]{report}
 
% the structure file contains all the packages that needs to be included to generate
% the main structure of the document
\include{structure/structure}
 
% Define a new glossary types
\newglossary[glg]{glossary}{gls}{glo}{Glosario}
\newglossary[slg]{symbol}{sym}{sbl}{Lista de Símbolos}
\newglossary[alg]{acronym}{acr}{acn}{Lista de Abreviaturas}
\makeglossaries
 
\include{acronyms/acronyms}  % include acronyms
\include{symbols/symbols}    % include symbols
\include{glossary/glossary}  % include glossary
 
\begin{document}
 
% custom background image command
\AddToShipoutPicture*{\BackgroundLogo}
 
\showboxdepth=-1
 
\include{front/front}
 
\thispagestyle{empty}
\hbox{}\vfill\hbox{}\pagebreak
\setcounter{page}{1}
 
% with this we prevent the paragraph alignment issue
\raggedbottom
 
% first use roman numerals for page numbers
\pagenumbering{roman}
 
% adding custom headers/footers defined above
\noneheads
\nonechapterheads
 
% including sections
\include{dedication/dedication}
\include{abstract/abstract}
\include{preface/preface}
\include{acknowledgments/acknowledgments}
 
% table of contents
\tableofcontents
\newpage % Begins on a new page instead of on the same page as the table of contents
 
% figure listings
\renewcommand\listfigurename{Lista de Figuras}
\listoffigures
\newpage
 
% code listings
\addcontentsline{toc}{chapter}{\lstlistlistingname}
\lstlistoflistings
\newpage
 
% set one blank space between paragraphs in empty line
%\setlength{\parskip}{\baselineskip}
 
% return page numbering to arabic
\pagenumbering{arabic}
 
\chapterheads
\commonheads
 
% including chapters
\include{chapters/1/introduction}
\include{chapters/2/theory}
 
% including appendixes
\begin{appendices}
  \include{appendixes/a/computer_programs}
\end{appendices}
 
% include glossaries
\printglossaries
 
\end{document}
</pre>
<p>As you can see in the code, the <em>include</em> latex command is used to include the other parts of the document from the main code file. The same technique is used for the chapters where the directory of the code files is added as well as the directory of the figures. Also, the bibliography files are added for each chapter including the directories. In this way <img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> constructs the document in parts according to the definitions in the code. Below is the example of a chapter with the definition of images, code and bibliography.</p>
<p><strong>introduction.tex</strong></p>
<pre class="brush: xml; title: ; notranslate">
\chapter{Introducción}
 
% code and figures paths
\graphicspath{{chapters/1/figures/}}
\lstset{inputpath=chapters/1/code/}
 
\lipsum. \cite{0071548297}
 
\section{Sección}
\lipsum
 
% abreviatura
\gls{fdtd}
 
% glosario
\glspl{debian}
 
\subsection{Subsección}
\lipsum
 
\section{Conclusiones}
\lipsum 
 
\bibliographystyle{unsrt}
\bibliography{chapters/1/introduction}
</pre>
<h2>Compiling</h2>
<p><img loading="lazy" src="https://www.imabit.com/wp-content/ql-cache/quicklatex.com-841cacb5479092c09838631b83f547bf_l3.png" class="ql-img-inline-formula quicklatex-auto-format" alt="&#36;&#92;&#76;&#97;&#84;&#101;&#88;&#36;" title="Rendered by QuickLaTeX.com" height="17" width="45" style="vertical-align: -4px;"/> Has multiple commands to compile the code and generate a beautiful document. Some of these commands are pdflatex, makeindex, makeglossaries, bibtex, among others. Each of these commands has a specific mechanism to create a pdf and may require several passes to complete the construction of the entire document. For simple documents there are several popular IDEs that automatically build the document by selecting configuration options graphically. It is also possible to define the compilation flow graphically. A simple example of an IDE that I personally use and recommend is <a href="http://kile.sourceforge.net/" target="_blank">Kile</a>, of course, open source and cross platform.</p>
<p><strong>makefile</strong></p>
<pre class="brush: bash; title: ; notranslate">
shell := /bin/bash
curr_date := $(shell /bin/date '+%Y-%m-%d_%H.%M.%S')
 
main_file = &quot;./thesis&quot;
output_file = &quot;./thesis&quot;
 
papers = &quot;../papers&quot;
output_file_papers = &quot;../build/thesis_papers_&quot;$(curr_date)
paper1_name = &quot;ACES_Journal_20150117_v3.pdf&quot;
paper2_name = &quot;APL_101_261902_2012.pdf&quot;
 
#chapters = &quot;chapters/1/introduction&quot; &quot;chapters/2/conclusions&quot;
 
# main entry point
all: aux glossary acronyms symbols bibliography pdf add_papers clean
 
# PDFLaTeX - first pass to generate aux files
aux:
    echo &quot;&gt;&gt;&gt;&gt;&gt; AUX&quot;
    pdflatex -interaction=nonstopmode $(main_file).tex
     
# MakeIndex - generate glossary files
glossary:
    echo &quot;&gt;&gt;&gt;&gt;&gt; GLOSSARY&quot;
    makeindex $(main_file).glo -s $(main_file).ist -t $(main_file).glg -o $(main_file).gls
 
# MakeIndex - generate acronyms files
acronyms:
    echo &quot;&gt;&gt;&gt;&gt;&gt; ACRONYMS&quot;
    makeindex $(main_file).acn -s $(main_file).ist -t $(main_file).alg -o $(main_file).acr
 
# MakeIndex - generate symbols files
symbols: 
    echo &quot;&gt;&gt;&gt;&gt;&gt; SYMBOLS&quot;
    makeindex $(main_file).sbl -s $(main_file).ist -t $(main_file).slg -o $(main_file).sym
 
# BibTex - generate chapters bibliography 
bibliography:
    echo &quot;&gt;&gt;&gt;&gt;&gt; BIBLIOGRAPHY&quot;
    # find name of chapters .tex files, remove extension and execute bibtex on the result
    find ./chapters -type f -name '*.tex' | while read f; do bibtex &quot;$${f%.*}&quot;; done
    #for chapter in $(chapters); do \
    #   bibtex $$chapter; \
    #done
 
# PDFLaTeX - last pass to generate final pdf files
pdf:
    echo &quot;&gt;&gt;&gt;&gt;&gt; PDF&quot;
    pdflatex -interaction=nonstopmode $(main_file).tex
    makeglossaries $(main_file).glo
    makeglossaries $(main_file).acn
    makeglossaries $(main_file).sbl
    pdflatex -interaction=nonstopmode $(main_file).tex
 
# Append papers pdf to generated thesis pdf
add_papers:
    echo &quot;&gt;&gt;&gt;&gt;&gt; ADD_PAPERS&quot;
    pdftk $(output_file).pdf $(papers)/$(paper1_name) $(papers)/$(paper2_name) cat output $(output_file_papers).pdf
 
# cd -; returns to previous dir
clean:
    echo &quot;&gt;&gt;&gt;&gt;&gt; CLEAN&quot;;
    # find and remove unneded extension files
    find . -name &quot;*.acn&quot; -o -name &quot;*.acr&quot; -o -name &quot;*.alg&quot; -o -name &quot;*.aux&quot; -o -name &quot;*.glg&quot; -o -name &quot;*.glo&quot; -o -name &quot;*.gls&quot; -o -name &quot;*.idx&quot; -o -name &quot;*.ist&quot; -o -name &quot;*.slg&quot; -o -name &quot;*.sym&quot; -o -name &quot;*.lof&quot; -o -name &quot;*.blg&quot; -o -name &quot;*.bbl&quot; -o -name &quot;*.toc&quot; -o -name &quot;*.sbl&quot; -o -name &quot;*.lol&quot; -type f | xargs rm;
</pre>
<p>There are many other considerations to take into account when structuring a doctoral thesis document but the truth is that it is not my intention to go into detail about each problem that had to be solved in order to get to the desired document. Instead, I have prepared an example <em>template</em> type that you can easily explore and adapt to your needs and hopefully you can save a good percentage of the hours that I had to invest to reach this result. Next I attach the file of the example and a pdf as the resulting document. Of course these files are designed to work in <strong>Linux</strong>.</p>
<p><strong>Sample template files</strong><br />
<a href="https://www.imabit.com/wp-content/uploads/2018/06/thesis_template.tar.xz" target="_blank"><img loading="lazy" src="https://www.imabit.com/wp-content/uploads/2018/06/application-x-xz.png" alt="pdf_icon" width="100" height="100" class="alignnone size-full wp-image-1112" /></a></p>
<p><strong>Pdf of the sample template</strong><br />
<a href="https://www.imabit.com/wp-content/uploads/2018/06/thesis.pdf" target="_blank"><img loading="lazy" src="https://www.imabit.com/wp-content/uploads/2018/06/pdf_icon.png" alt="pdf_icon" width="100" height="100" class="alignnone size-full wp-image-1112" /></a></p>
<p>¡Enjoy! <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f600.png" alt="😀" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2018/06/doctoral-thesis-structure-proposal/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Using Google Apps Scripts</title>
		<link>https://www.imabit.com/2018/06/using-google-apps-scripts/</link>
					<comments>https://www.imabit.com/2018/06/using-google-apps-scripts/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Mon, 11 Jun 2018 23:37:09 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=538</guid>

					<description><![CDATA[Versión en español de esta publicación. If you like email as much as me and you use GMail as your primary email provider it is possible that you already had the same problem as I had some time ago. It turns out that in GMail it is possible to organize your email using labels that&#8230;&#160;<a href="https://www.imabit.com/2018/06/using-google-apps-scripts/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Using Google Apps Scripts</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2017/10/utilizando-google-apps-script/" target="_blank">Versión en español de esta publicación.</a><br />
If you like email as much as me and you use GMail as your primary email provider it is possible that you already had the same problem as I had some time ago. It turns out that in GMail it is possible to organize your email using labels that is the same analogy as organize files in folders. In my case, I have my email organized using multiple labels and using also sub labels and I&#8217;m a heavy fan of GMail filters which can automatically apply a label to a new email that arrive and put that email in specific &#8220;folder&#8221;.<br />
<span id="more-538"></span></p>
<p>This GMail filtering system is very useful and powerful. The problem raise when you have to mark all email in some of the labels as <em>read</em>. And I say problem because the real problem comes up when trying to mark all email in a label and all the corresponding sub labels at any level as read automatically. And this is simply not supported by GMail.</p>
<p><strong>Google Apps Scripts to the Rescue</strong><br />
It turns out that Google has a variety of APIs for all its products that can be used to interact with them from a defined language, in this case Javascript. The APIs are quite friendly and easy to use. Also, the documentation is excellent and highly understandable. And not to do the long story, I created a script to do just that, mark as read all emails under a defined tag including all child tags.</p>
<pre class="brush: jscript; title: ; notranslate">
function markLabelThreadsAsRead(label) {
  var labels = GmailApp.getUserLabels();
  for (var i = 0; i &lt; labels.length; i++) {
    var index = labels[i].getName().indexOf(label, 0);
    if (index === 0) { // if label name starts with parent label name
      Logger.log(&quot;processing label:&quot; + labels[i].getName());
      // batch processing ref: https://gist.github.com/gene1wood/0f455239490e5342fa49
      var batchSize = 100 // Process up to 100 threads at once
      var threads = GmailApp.search(&quot;label:&quot; + labels[i].getName() + &quot; is:unread&quot;);
      for (j = 0; j &lt; threads.length; j+=batchSize) {
        Logger.log(&quot;mark thread as read:&quot; + threads[j].getFirstMessageSubject());
        GmailApp.markThreadsRead(threads.slice(j, j+batchSize));
      }     
    }
  } 
}

markLabelThreadsAsRead(&quot;ParentLabel&quot;);
</pre>
<p>To run the script simply visit the Google online editor (<a href="https://script.google.com/" rel="noopener" target="_blank"> https://script.google.com/ </a>), paste the script there and then you can press the run or debug option. The APIs documentation can be found here <a href="https://developers.google.com/apps-script/overview" rel="noopener" target="_blank">https://developers.google.com/apps-script/overview</a>.</p>
<p>Enjoy! =)<br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2018/06/using-google-apps-scripts/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>How to send Awstats as an Email</title>
		<link>https://www.imabit.com/2017/05/send-awstats-email/</link>
					<comments>https://www.imabit.com/2017/05/send-awstats-email/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Tue, 16 May 2017 00:27:39 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=482</guid>

					<description><![CDATA[Versión en español de esta publicación. Some months ago I installed Awstats in my home server (but that&#8217;s not covered in this post). The problem I had is that I barely check the URLs to see my sites statistics because is hard to remember to do so. I&#8217;m the kind of guy that puts more&#8230;&#160;<a href="https://www.imabit.com/2017/05/send-awstats-email/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">How to send Awstats as an Email</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2017/04/como-enviar-awstats-directo-al-correo/" target="_blank">Versión en español de esta publicación.</a><br />
Some months ago I installed <a href="http://www.awstats.org/" target="_blank">Awstats</a> in my home server (but that&#8217;s not covered in this post). The problem I had is that I barely check the URLs to see my sites statistics because is hard to remember to do so.<br />
<span id="more-482"></span></p>
<p>I&#8217;m the kind of guy that puts more attention to email when it comes to data or system alerts. So I decided that, to send my site statistics to my email instead of having to use the password protected url to see them. I started to search a plugin or a built-in functionality to do this in the simplest way possible in order to not spend time getting this to work. Maybe I did not search enough because I didn&#8217;t found a way to do it automatically. </p>
<p>So I started to look at some options to accomplish sending my site stats to the email. Here is the approach that I came up with. Maybe it can be useful to someone.</p>
<pre class="brush: bash; title: ; notranslate">
function send_awstats() {
    # Download awstats for all sites. Send them as html email 
    for ((i = 0; i &lt; ${#__server_sites[@]}; i++)); do
        wget --tries=3 --output-document=/tmp/${__server_sites[$i]}.html --no-check-certificate --user user --password pass https://awstats/url/?config=${__server_sites[$i]}
        mail -a &quot;MIME-Version: 1.0&quot; -a &quot;Content-Type: text/html&quot; -s &quot;Daily Awstats [${__now}]: ${__server_sites_domains[$i]}&quot; root@localhost &lt; /tmp/${__server_sites[$i]}.html
        rm -f /tmp/${__server_sites[$i]}.html
    done
}
</pre>
<p>Basically what this script does is that it makes a request to the Awstats url and saves the content as an html file in a temporal directory. After that it sends the saved file as an html email. In order for this to work you have to have Awstats installed and also postfix for sending emails.</p>
<p>This script can be placed in a .sh file and setup a cron job to periodically and according to your needs send the email with the latest site statics data.</p>
<p>Enjoy!<br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2017/05/send-awstats-email/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Module Headers AutoGenerated Code (Bash &#8211; C++)</title>
		<link>https://www.imabit.com/2017/01/module-headers-autogenerated-code-bash-c/</link>
					<comments>https://www.imabit.com/2017/01/module-headers-autogenerated-code-bash-c/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Thu, 12 Jan 2017 05:45:27 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=465</guid>

					<description><![CDATA[Versión en español de esta publicación. Some time ago when I started designing Phoxonics I had some problems related to generating module includes. Phoxonics has multiple modules that have dependencies between them, and when adding a new header class it was necessary to add an entry for this header class in the global module header&#8230;&#160;<a href="https://www.imabit.com/2017/01/module-headers-autogenerated-code-bash-c/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Module Headers AutoGenerated Code (Bash &#8211; C++)</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2017/04/como-enviar-awstats-directo-al-correo/" target="_blank">Versión en español de esta publicación.</a><br />
Some time ago when I started designing Phoxonics I had some problems related to generating module includes. Phoxonics has multiple modules that have dependencies between them, and when adding a new header class it was necessary to add an entry for this header class in the global module header file in order to know what classes were part of this module.<br />
<span id="more-465"></span></p>
<p>So I decided to make a small script to automate this simple task that was becoming tedious to do just because of the fact that one needed to remember to add an entry to the global header file each time a new header class was added. With this script it is not needed anymore to remember to add any entry to the global module file cause in the build target we added a reference to the new bash script that generates automatically all the header reference that are contained in the actual module. </p>
<p>Here is the script code for the automatic generation of C++ header code. I hope you find it useful.</p>
<pre class="brush: bash; title: ; notranslate">
module_name=&quot;${1}&quot;
module_name_upper=${module_name^^}  # Module name in uppercase
 
# Run as user, -e allows to interpret new line \n
echo -e &quot;\n \
********************************************************** \n \
** Automatic header generation for module ${module_name} \n \
**********************************************************&quot;
 
inc_dir=&quot;${2}&quot;
out_file=&quot;${3}&quot;
 
# &quot;ls -l $inc_dir&quot;        = get a directory listing
# --time-style=&quot;long-iso&quot; = makes sure that the same format for the date-time string is the same in all environments.
# &quot;| egrep '^d'&quot;          = pipe to egrep and select only the directories
# &quot;awk '{print $8}'&quot;      = pipe the result from egrep to awk and print only the 8th field
inc_dirs=`ls -l --time-style=&quot;long-iso&quot; $inc_dir | egrep '^d' | awk '{print $8}'`
 
cat &lt;&lt;EOF &gt;&quot;${out_file}&quot;
/*
 * ${module_name}.hpp
 *
 * Auto-Generated module header file, do not modify directly
 * to prevent changes loss, to modify please change GenHeaders.sh
 * 
 *  Created on: 2014
 *      Author: nano
 */
 
#ifndef ${module_name_upper}_HPP_
#define ${module_name_upper}_HPP_
 
// Include all headers that are part of the ${module_name} module
EOF
 
# Loop through the directories
for dir in ${inc_dirs}; do
    echo -e &quot;\n${dir}&quot;;  
    curr_dir=${inc_dir}/${dir}
    file_cnt=$( find ${curr_dir} -name &quot;*.h*&quot; | wc -l )
    curr_files=$( find ${curr_dir} -name &quot;*.h*&quot; )
    if [ ${file_cnt} -gt 0 ]; then  # check  if we have headers in dir
        for file in ${curr_files}; do # Loop through files and add includes
            echo &quot;#include \&quot;${file}\&quot;&quot; &gt;&gt; ${out_file};
            echo &quot;${file}&quot;;
        done       
    fi
done
echo -e &quot;\n&quot;;
 
# Add closing ifdef    
echo &quot;&quot; &gt;&gt; ${out_file}
echo &quot;#endif /* ${module_name_upper}_HPP_ */&quot; &gt;&gt; ${out_file}
</pre>
<p>And here are some autogenerated entries in the global header module file.</p>
<pre class="brush: cpp; title: ; notranslate">
/*
 * common.hpp
 *
 * Auto-Generated module header file, do not modify directly
 * to prevent changes loss, to modify please change GenHeaders.sh
 * 
 *  Created on: 2014
 *      Author: nano
 */

#ifndef COMMON_HPP_
#define COMMON_HPP_

// Include all headers that are part of the common module
#include &quot;./include/common/CommonBase.hpp&quot;
#include &quot;./include/data/Config.hpp&quot;
#include &quot;./include/data/Programs.hpp&quot;
#include &quot;./include/data/VersionInfo.hpp&quot;
#include &quot;./include/exception/CustomException.hpp&quot;
#include &quot;./include/hdf5/Hdf5Grid2D.hpp&quot;
#include &quot;./include/hdf5/Hdf5Grid2DSlice.hpp&quot;
#include &quot;./include/hdf5/Hdf5Grid1DSlice.hpp&quot;
#include &quot;./include/hdf5/Hdf5Grid1D.hpp&quot;
#include &quot;./include/hdf5/Hdf5Base.hpp&quot;
#include &quot;./include/io/Folder.hpp&quot;
#include &quot;./include/io/File.hpp&quot;
#include &quot;./include/utils/DateTime.hpp&quot;
#include &quot;./include/utils/Logger.hpp&quot;
#include &quot;./include/utils/Formatter.hpp&quot;
#include &quot;./include/utils/ArrSizeHelper.hpp&quot;
#include &quot;./include/utils/Matrix.hpp&quot;
#include &quot;./include/utils/Utilities.hpp&quot;
#include &quot;./include/utils/Strings.hpp&quot;
#include &quot;./include/utils/Command.hpp&quot;
#include &quot;./include/utils/SingleLoggerConfig.hpp&quot;

#endif /* COMMON_HPP_ */
</pre>
<p>Enjoy!<br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2017/01/module-headers-autogenerated-code-bash-c/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Traceability in Lua Functions</title>
		<link>https://www.imabit.com/2017/01/traceability-lua-functions/</link>
					<comments>https://www.imabit.com/2017/01/traceability-lua-functions/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Mon, 09 Jan 2017 03:33:58 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=457</guid>

					<description><![CDATA[Versión en español de esta publicación. This weekend I&#8217;ve been working on some lua scripts with which I was having some problems debugging the flow of the code. I decided to write a small function in order to print some information of the current function flow and parameter values. The first function presented below receives&#8230;&#160;<a href="https://www.imabit.com/2017/01/traceability-lua-functions/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Traceability in Lua Functions</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2017/01/trazabilidad-en-funciones-de-lua/" target="_blank">Versión en español de esta publicación.</a><br />
This weekend I&#8217;ve been working on some lua scripts with which I was having some problems debugging the flow of the code. I decided to write a small function in order to print some information of the current function flow and parameter values.<br />
<span id="more-457"></span></p>
<p>The first function presented below receives the current function name as first parameter and a parameter list that is used to create a nice formated flow function string to print. The second function is an example on how to use the first function to print the flow.</p>
<pre class="brush: bash; title: ; notranslate">
local function debug_print_trac(func, ...)
    local res = func .. &quot;( &quot;;
    for i,v in ipairs(arg) do
        res = res .. tostring(v) .. &quot; &quot;;
    end
    res = res .. &quot; )&quot;;
    debug_print(res);
end
 
local function set_monitor(monitor)
    debug_print_trac(debug.getinfo(1, &quot;n&quot;).name, monitor);
    if (monitor == &quot;principal&quot;) then
        set_window_position(0,0);
    else
        set_window_position(2561,0);
    end
end
</pre>
<p>And here are some printed results of function calls. We have our current flow functions and its parameters values printed.</p>
<pre class="brush: plain; title: ; notranslate">
set_top( false  )
Window Name: The Linux Programming Interface
Application name: Document Viewer
max_in( principal 4 false  )
set_monitor( principal  )
</pre>
<p>¡Cheers!<br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2017/01/traceability-lua-functions/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Git Notes</title>
		<link>https://www.imabit.com/2016/12/git-notes/</link>
					<comments>https://www.imabit.com/2016/12/git-notes/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Sat, 03 Dec 2016 04:28:23 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">https://www.imabit.com/?p=415</guid>

					<description><![CDATA[Versión en español de esta publicación. Git is a very robust and flexible source code control system that allows code versioning in a simple and fast way, it was created by Linus Torvalds with the idea of replacing the sotware that was used maintain the code versioning of the Linux kernel which converted from open&#8230;&#160;<a href="https://www.imabit.com/2016/12/git-notes/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Git Notes</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2016/12/notas-de-git/" target="_blank">Versión en español de esta publicación.</a><br />
<a href="https://en.wikipedia.org/wiki/Git" target="_blank">Git</a> is a very robust and flexible source code control system that allows code versioning in a simple and fast way, it was created by Linus Torvalds with the idea of replacing the sotware that was used maintain the code versioning of the Linux kernel which converted from open source to closed source.<br />
<span id="more-415"></span></p>
<p>Git uses a distributed repositories paradigm which means that every client has a complete copy of the whole code repository which makes working with the code be possible even without a network connection, this is the main difference between the centralized systems like subversion which requires a network connection in order to checkout files for editing and/or deleting.</p>
<p>This guide does not pretend to be a complete reference of git commands and descriptions, that guide <a href="https://git-scm.com/book/en/v2" target="_blank">already exists</a>, instead, this guide pretends to help people that wants to start learning how to use git as a source code control in a fast manner and want to start to be productive using this tool as soon as possible.</p>
<h2>Configuration</h2>
<p>Basically, the first thing to do after installing git is to configure its global options in order to use git effectively. First we need to increment the post buffer size to be able to post large files into our repository. We do that in the following way </p>
<pre class="brush: bash; title: ; notranslate">
# increment git post buffer to 500MB
git config --global http.postBuffer 524288000
</pre>
<p>Next, we need to establish a credential helper cache of 10 hours to not have git to be asking for credentials every pull and/or push we make to our repository</p>
<pre class="brush: bash; title: ; notranslate">
# cache credentials for 10 hours
git config --global credential.helper cache
git config --global credential.helper &quot;cache --timeout=36000&quot;
</pre>
<p>After that we setup some console output color just to make the shell more attractive <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /></p>
<pre class="brush: bash; title: ; notranslate">
# and give some love to the git output
git config --global color.ui auto
git config --global color.branch auto
git config --global color.diff auto
git config --global color.status auto
</pre>
<p>After that, we need to set some identity information like the user name and email, this data is going to appear in each commit we do to our repositories</p>
<pre class="brush: bash; title: ; notranslate">
# add commit global information
git config --global user.name &quot;Yohan Jasdid&quot;
git config --global user.email yohan.jasdid@gmail.com
git config --global push.default simple
</pre>
<p>Then, we have the mergetool configuration, the merge tool is the tool used to resolve any issue at the moment of making any merge between branches, this tool usually shows the differences between local and remote files and allow us to resolve any conflicts in a visual and easy way, in this case I use kdiff but of course there are many good merge tools that you can use</p>
<pre class="brush: bash; title: ; notranslate">
# configure merge tool global setting
git config --global --add merge.tool kdiff3
git config --global --add mergetool.kdiff3.path &quot;/usr/bin/kdiff3&quot;
git config --global --add mergetool.kdiff3.trustExitCode false
</pre>
<p>After the mergetool we setup the diff tool, this is the tool that will be used when showing differences between revisions, here again I&#8217;m using kdiff</p>
<pre class="brush: bash; title: ; notranslate">
# configure diff tool global setting
git config --global --add diff.guitool kdiff3
git config --global --add difftool.kdiff3.path &quot;/usr/bin/kdiff3&quot;
git config --global --add difftool.kdiff3.trustExitCode false
</pre>
<p>Lastly, I added a setting to disable the SSL certificate. This was just because I&#8217;m using a self signed certificate in my source control server and git is unable to verify the authenticity of the certificate, I should get rid of this setting once I use a letsencrypt certificate </p>
<pre class="brush: bash; title: ; notranslate">
# disable ssl checking (not recommended for global)
git config --global http.sslVerify false
</pre>
<h2>Cloning Repos</h2>
<p>Cloning a repository in git means that we will obtain a full copy of the remote repository in the local machine, to do this we use the following command</p>
<pre class="brush: bash; title: ; notranslate">
# clone a repository
git clone https://my_repo.git
</pre>
<h2>Branching</h2>
<p>Git is based on the concept of branching, all branches basically have a parent which they&#8217;re based on, a branch can be seen as a snapshot of the current repository at the moment of creating the branch. The new created branch is intended to contain a set of code that can be integrated on the main branch or any other branch.</p>
<pre class="brush: bash; title: ; notranslate">
# create branch
git branch &lt;branch_name&gt;
 
# create and move to branch
git checkout -d &lt;branch_name&gt;
</pre>
<p>There are 2 types of branches, local and remote branches. Once a local branch has been created it need to be pushed in order to create the remote branch mapped to the local branch. To push the local branch we use the following command</p>
<pre class="brush: bash; title: ; notranslate">
# send local branch to origin in case the branch is just local and start tracking remote branch with local branch
git push origin &lt;branch_name&gt;
</pre>
<p>And to push the local branch and map it to a remote branch we use</p>
<pre class="brush: bash; title: ; notranslate">
# send local branch to origin and map with remote branch
git push --set-upstream origin &lt;branch_name&gt;
</pre>
<p>Once we have created branches in our repository, we may need to delete some of this branches, to do that we can use the following commands, to delete a branch safely or forcedly</p>
<pre class="brush: bash; title: ; notranslate">
# delete local branch (safely)
git branch -d &lt;branch_name&gt;
 
# delete local branch (forced)
git branch -D &lt;branch_name&gt;
 
# delete remote branch
git push origin --delete &lt;branch_name&gt;
</pre>
<p>If we want to see a list of local or remote branches we can do this by executing the following commands</p>
<pre class="brush: bash; title: ; notranslate">
# show local branches
git branch
 
# show all branches (local and remote)
git branch -a
</pre>
<p>After using or deleting branches is necessary to do a clean up and update the references to the current branches. We can do this by using the following commands</p>
<pre class="brush: bash; title: ; notranslate">
# Update references to remote branches, if remote branch is deleted then with this command the branch list gets updated
git remote prune origin
</pre>
<p>Once we have work with branches, we probably have the need to make changes in branches that are available remotely and that are not owned by us. To do that we first need to retrieve the branch locally so we can make the desired changes. There are some known ways to do that , the two most used ways are to retrieve a remote branch and map it to a local branch that has a different name and to retrieve a remote branch and map it to a local branch with the same name respectively, to do that we use the following commands  </p>
<pre class="brush: bash; title: ; notranslate">
# Checkout a remote branch and track it locally (it is possible to use different names for local and remote branches)
git checkout -b &lt;local_branch&gt; origin/&lt;remote_branch&gt;       # Will create &lt;local_branch&gt; and track origin/&lt;remote_branch&gt;
 
# Checkout a remote branch and track it locally (it is NOT possible to use different names for local and remote branches)
git checkout --track origin/&lt;remote_branch&gt;                # Will only create '&lt;remote_branch&gt;', not a branch with a different name
</pre>
<p>There are times when something goes wrong in a local branch and we just want to simply regenerate the local branch based on the remote branch, to do that we use the reset command in the following way</p>
<pre class="brush: bash; title: ; notranslate">
# Force replace local branch with remote branch
git reset --hard origin/&lt;remote_branch&gt;
</pre>
<p>Also, there are times when is useful to simply delete the local branch and create it again using the remote branch, to do that we use this commands</p>
<pre class="brush: bash; title: ; notranslate">
# Recreate branch locally
git checkout master
git branch -D &lt;local_branch&gt;
git checkout --track origin/&lt;remote_branch&gt;
</pre>
<h2>Add</h2>
<p>Once we have understand and mastered branches and is time to do a code change or simply develop a new feature in the system, we proceed to make our changes, git is smart, at the moment we do our changes in a branch git automatically recognizes them and it display them when we type the following command</p>
<pre class="brush: bash; title: ; notranslate">
# show status of modified files detected by git
git status
</pre>
<p>In git there are different states of the files, there is a state called untracked, that means that git detected a fie that had never been tracked by git, there is also the tracked state, that means that git already tracked changes for that file but is in a modified state at the moment. Wherever the state of the file change is, if we want to integrate the change into our local branch and then into the remote branch, we first need to add the change to staging, the staging area is the area that identifies all the file changes we want to add to the repository, to add a file change to staging we use the following command</p>
<pre class="brush: bash; title: ; notranslate">
# adds a file to staging
git add &lt;file_name&gt;
</pre>
<p>There are probably many changes that we want to add to staging at the same time at once, and to avoid being adding changes one by one, we can use pattern matching and add a bunch of changes to staging at once like this</p>
<pre class="brush: bash; title: ; notranslate">
# add all files with pattern match to staging
git add *
 
# add all files with pattern match to staging
git add .
</pre>
<p>And lastly, we can add only the untracked file changes to staging with the following command</p>
<pre class="brush: bash; title: ; notranslate">
# add all files that are untracked to staging
git add -u
</pre>
<h2>Commits</h2>
<p>Once we have added a change or group of changes to staging, we can proceed to make commits, a commit is basically a change or a group or changes encapsulated in a sort of bag with an ID that is a hash that git generates, to generate a commit or &#8220;bag of changes&#8221; we can use the following commands</p>
<pre class="brush: bash; title: ; notranslate">
# Standard commit with simple message
git commit -m &quot;Message of commit&quot;
 
# Commit with message and description - this commit is intended for when having a title and a long description
git commit -m &quot;Title of commit&quot; -m &quot;Detail message of commit&quot;
</pre>
<h2>Pushing</h2>
<p>Once we have our commit of changes or group of commits of changes in place in our local branch, what we want to do now is to send these changes to the remote branch to make them publicly available, this is what the push command does for us, is worth mentioning that the push command can push a branch with changes to the remote repository or just a sets of changes in a branch that already exists remotely, we do that by using the following commands</p>
<pre class="brush: bash; title: ; notranslate">
# Send all changes that are already in commits to remote repository that is tracked
git push
 
# Send local branch to origin in case the branch is just local and start tracking remote branch with local branch
git push origin &lt;branch_name&gt;
</pre>
<h2>Revert</h2>
<p>There are cases were for whatever reason we decide to undo all the local changes we already did to a file or group of files or just undo all the changes we made to all files, to this effect we use the following commands</p>
<pre class="brush: bash; title: ; notranslate">
# revert a file to a commit state
git checkout &lt;commit_hash&gt; path/to/file
 
# discard file changes 
git checkout path/to/file
 
# discard file changes with pattern matching
git checkout .
</pre>
<h2>Stash and Clean</h2>
<p>There are also some times when we start making changes and developing new functionality in the system and we realize that we were not doing this changes in the correct branch, what can I do then?, we use git stash!. The stash commands allow us to save a change or group of changes in some kind of temporary location which allow us to switch to another branch and restore all changes, nice!, we do this by using the following command</p>
<pre class="brush: bash; title: ; notranslate">
# when having changes in different branch and want them to move to another branch use git stash
# git stash saves changes to a temporary location and applies them with a command
# sample workflow to move changes from one branch to another
git checkout &lt;branch_name&gt;       # move to a branch
&lt;make some changes&gt;
git stash                        # stash the changes in temp location
git checkout &lt;another_branch&gt;    # move to a different branch
git stash pop                    # apply the last stash changes to &lt;another_branch&gt; and drops the stash from the stack
</pre>
<p>Git stash also allows to save one set or many set of changes, to see all sets of changes available by git stash we use the following command</p>
<pre class="brush: bash; title: ; notranslate">
# shows a list of stashes. there can be more than one stash in form of a list
git stash list
</pre>
<p>There are times that the local and remote branches diverge, in this case what we want to do is regenerate the local branch, and we can do that with the reset commands in the following way</p>
<pre class="brush: bash; title: ; notranslate">
# when remote and local branches had diverged you can use reset to reset your local branch
# and sync with the remote branch
git fetch
git reset --hard origin/&lt;branch_name&gt;
</pre>
<p>There are other cases that we added a bunch of new files to the branch that we realize that were not needed to be added and we want to remove them, in that case we can use the clean command like this</p>
<pre class="brush: bash; title: ; notranslate">
# delete untracked files - show untracked files to delete using the -n option:
git clean -f -n
 
# delete untracked files - beware: this will delete files
git clean -f
</pre>
<p>We can also discard all added changes with the following command</p>
<pre class="brush: bash; title: ; notranslate">
# remove all changes in current branch and checkout branch changes
git checkout .
</pre>
<h2>Log and Show</h2>
<p>Once we have branches, commits, pushed commits and a change history, we may regularly need to query our repository for the list of latest commits done. This is useful to find a specific change or just to see who made some change. To do this, we use the log command which is very useful, we can show a list of changes with descriptions like this</p>
<pre class="brush: bash; title: ; notranslate">
# show commits history with descriptions
git log
</pre>
<p>And if we want to look for all the commits done by a certain author we can do this</p>
<pre class="brush: bash; title: ; notranslate">
# show commits history with descriptions of a certain author
git log --author=bob
</pre>
<p>To show the commit history in a one line per change and/or with decoration format we can do the following</p>
<pre class="brush: bash; title: ; notranslate">
# to see a very compressed log where each commit is one line
git log --pretty=oneline
 
# to see an ASCII art tree of all the branches, decorated with the names of tags and branches
git log --graph --oneline --decorate --all
</pre>
<p>To show only the modifies files, we do</p>
<pre class="brush: bash; title: ; notranslate">
# see only which files have changed
git log --name-status
</pre>
<p>And to display the command help we use</p>
<pre class="brush: bash; title: ; notranslate">
# show help for log
git log --help
</pre>
<p>To show the differences between commits between branches we do</p>
<pre class="brush: bash; title: ; notranslate">
# show commit difference between branches
git log master..&lt;branch_name&gt;
</pre>
<p>And to show the details of a commit, we do</p>
<pre class="brush: bash; title: ; notranslate">
# show commit diff details
git show &lt;commit_hash&gt;
</pre>
<h2>Diff</h2>
<p>There is another useful command called diff that allow us to view all differences between branches or commits. We use this command in the following way</p>
<pre class="brush: bash; title: ; notranslate">
# show changes between source and target branches
git diff &lt;source_branch&gt; &lt;target_branch&gt;
 
# show changes between commit's ancestor and commit
git diff &lt;commit_hash&gt;~ &lt;commit_hash&gt;
 
# show modified files between branches
git diff --name-only &lt;source_branch&gt; &lt;target_branch&gt;
 
# show file differences between branches
git diff --name-status &lt;branch1&gt;..&lt;branch2&gt;
 
# show file content differences between branches
git diff &lt;branch1&gt; &lt;branch2&gt; -- &lt;file_path_name&gt;
</pre>
<h2>Tags</h2>
<pre class="brush: bash; title: ; notranslate">
# it's recommended to create tags for software releases. this is a known concept, create a new tag named 1.0.0 with this command
# the 1b2e1d63ff stands for the first 10 characters of the commit id you want to reference with your tag.
git tag 1.0.0 1b2e1d63ff
 
# Show tag list
git tag
 
# Create a breanch based on tag
git checkout -b &lt;branch_name&gt; &lt;tag_name&gt;
</pre>
<h2>Escenarios</h2>
<pre class="brush: bash; title: ; notranslate">
# Usually at home in my server I'll do the following
git checkout development   # Move to dev branch
Do some programming.
git status                              # to see what files I changed.
git diff [file]                           # to see exactly what I modified.
git add .                               # to stage all changes
git commit -m [message]     # to commit.
git push                               # push changes to branch
 
# Steps to fast forward merge from development branch into master and return to development to continue working
git checkout master &amp;&amp; git pull &amp;&amp; git merge development &amp;&amp; git push &amp;&amp; git checkout development
</pre>
<h2>References</h2>
<ul>
<li>Git &#8211; Home: <a href="https://git-scm.com/" target="_blank">https://git-scm.com/</a></li>
<li>Git &#8211; Reference: <a href="https://git-scm.com/docs" target="_blank">https://git-scm.com/docs</a></li>
<li>Git &#8211; The Simple Guide: <a href="http://rogerdudler.github.io/git-guide/" target="_blank">http://rogerdudler.github.io/git-guide/</a></li>
<li>Git &#8211; Documentation: <a href="https://git.wiki.kernel.org/index.php/GitDocumentation" target="_blank">https://git.wiki.kernel.org/index.php/GitDocumentation</a></li>
<li>Git &#8211; Understanding Git Conceptually: <a href="https://www.sbf5.com/~cduan/technical/git/" target="_blank">https://www.sbf5.com/~cduan/technical/git/</a></li>
</ul>
<p>Cheers!<br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2016/12/git-notes/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Installing Nvidia Drivers and CUDA 7.5 in Debian Jessie</title>
		<link>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-5-in-debian-jessie/</link>
					<comments>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-5-in-debian-jessie/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Sat, 22 Oct 2016 05:34:31 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">http://www.imabit.com/?p=391</guid>

					<description><![CDATA[Versión en español de esta publicación. This tutorial explains how to install CUDA 7.5 Production Release in a Debian Jessie system, the first thing we have to do is to download the graphics driver from Nvidia website and select the current model of the graphics card we have, in my case I have a server&#8230;&#160;<a href="https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-5-in-debian-jessie/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Installing Nvidia Drivers and CUDA 7.5 in Debian Jessie</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2016/01/instalando-los-drivers-de-nvidia-y-cuda-7-5-en-debian-jessie/" target="_blank">Versión en español de esta publicación.</a><br />
This tutorial explains how to install CUDA 7.5 Production Release in a Debian Jessie system, the first thing we have to do is to download the graphics driver from Nvidia website and select the current model of the graphics card we have, in my case I have a server with 2 Nvidia cards the first one is a GeForce GTX660 and the second one is a GeForce GTX650, if you&#8217;re not sure of which driver version you should install, you can check the driver versions and models in the following link<span id="more-391"></span></p>
<p><a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a></p>
<p>The latest driver version available for my cards is 352.79 and is available at <a href="http://us.download.nvidia.com/XFree86/Linux-x86_64/352.79/NVIDIA-Linux-x86_64-352.79.run" target="_blank">http://us.download.nvidia.com/XFree86/Linux-x86_64/352.79/NVIDIA-Linux-x86_64-352.79.run</a>, please make sure to download the latest version of your card driver.</p>
<p>Also we need to download the CUDA toolkit 7.5 from located at <a href="http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run" target="_blank">http://developer.download.nvidia.com/compute/cuda/7.5/Prod/local_installers/cuda_7.5.18_linux.run</a>. The installer file of the toolkit needed is the Linux <strong>RUN</strong> file for Ubuntu, the file name is: <em>cuda_7.5.18_linux.run</em>.</p>
<p>Now we need to verify the requirements to install CUDA. First we need a capable GPU device. </p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify we have a cuda capable gpu
lspci | grep -i nvidia
</pre>
<p>We need to check our Linux version</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# Linux version
uname -m &amp;&amp; cat /etc/*release
</pre>
<p>Now we need to verify that we have a valid GCC compiler</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify gcc version 
gcc --version
</pre>
<p>If you don&#8217;t have a valid GCC compiler installed please install it by running the following command</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# gcc install
sudo apt-get install build-essential
</pre>
<p>Before we proceed with the actual installation process we need to uninstall any version of CUDA we had installed previously, if this is the first time you install CUDA please skip this step, we uninstall previous installations by running the following command</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda uninstall
sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl
</pre>
<p>Where X and Y is the cuda version. If we are upgrading the Nvidia driver we don&#8217;t have to do anything just because the installer itself removes old driver versions. If we want to uninstall the CUDA driver just run the following command.</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda driver uninstall
sudo /usr/bin/nvidia-uninstall
</pre>
<p>Once we have completed the steps above and have downloaded the files needed for the installation we proceed to disable the nouveau driver which is the default driver for Debian, we do that by creating a new file: </p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# edit debian driver configuration file
vim /etc/modprobe.d/disable-nouveau.conf 
</pre>
<p>And add the following content to it</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# blacklist defualt driver
blacklist nouveau
options nouveau modeset=0
</pre>
<p>Note: to verify that we have the nouveau driver running, just run the following command, if it outputs something it means that we actually have a nouveau driver running</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify driver
lsmod | grep nouveau
</pre>
<p>After having the file for blocking the default driver in place, we proceed to restart the machine in <em>default</em> mode. Once restarted we are going to note that the screen resolution got at a lower level and that means that the default driver was not loaded, then we need to get some header files from our repository to build the Nvidia driver, we do this by executing the following command.</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# dependencies
sudo apt-get install linux-headers-$(uname -r)
</pre>
<p>After installing this files we proceed to remove the nouveau driver completely from our system by executing the following command</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# remove
apt-get remove --purge xserver-xorg-video-nouveau
</pre>
<p>After the removal of the driver has happened we need to restart our system in <strong>recovery</strong> mode, once restarted in recovery mode and having the nice console interface we proceed with the driver installation process, first we need to know which version of the compiler was used to compile the current system kernel, this because the system needs to compile the Nvidia driver, if we don&#8217;t know which version was used and which kernel we have, we can find that out by running the following command</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# find curr gcc version
cat /proc/version
</pre>
<p>Once we know the correct compiler version, we need to set it up with an export like this</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# set gcc version
export CC=gcc-4.8
</pre>
<p>Now we can proceed with the driver installation, we navigate to our download path and execute the driver</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute driver install
sudo sh NVIDIA-Linux-x86_64-346.47.run
</pre>
<p>Once the installation is finished we proceed to reboot the machine and we&#8217;re going to note that we have a nice screen resolution and our new Nvidia drivers installed, next we proceed with the toolkit installation like this.</p>
<p><b>cuda7_5_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute toolkit install
sudo sh cuda_7.5.18_linux.run
</pre>
<p>When prompted we need to select <strong>not</strong> to install the Nvidia driver since we already installed it, and choose the default path for the samples (recommended).<br />
The last thing to do is to compile the samples and run them, to do this we navigate to the samples directory that we choose and just execute a <strong>make</strong> command</p>
<p>And that&#8217;s it!</p>
<p><strong>Here are some useful links related to CUDA 7.5</strong></p>
<p>The CUDA getting started manual which covers in deep installation instructions<br />
<a href="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf" title="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf" target="_blank">http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf</a> </p>
<p>The CUDA downloads page<br />
<a href="https://developer.nvidia.com/cuda-downloads" title="https://developer.nvidia.com/cuda-downloads" target="_blank">https://developer.nvidia.com/cuda-downloads</a></p>
<p>The Nvidia Driver downloads page<br />
<a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" title="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a></p>
<p>A blog post of the CUDA 7.5 features<br />
<a href="https://devblogs.nvidia.com/parallelforall/new-features-cuda-7-5/" target="_blank">https://devblogs.nvidia.com/parallelforall/new-features-cuda-7-5/</a></p>
<p>The Nvidia CUDA toolkit 7.5<br />
<a href="http://developer.download.nvidia.com/compute/cuda/7.5/Prod/docs/sidebar/CUDA_Toolkit_Release_Notes.pdf" target="_blank">http://developer.download.nvidia.com/compute/cuda/7.5/Prod/docs/sidebar/CUDA_Toolkit_Release_Notes.pdf</a></p>
<p>Have Fun! <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-5-in-debian-jessie/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>Installing Nvidia Drivers and CUDA 7.0 in Debian Wheezy</title>
		<link>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-0-in-debian-wheezy/</link>
					<comments>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-0-in-debian-wheezy/#respond</comments>
		
		<dc:creator><![CDATA[yohan.jasdid]]></dc:creator>
		<pubDate>Sat, 22 Oct 2016 05:30:17 +0000</pubDate>
				<category><![CDATA[Blog]]></category>
		<guid isPermaLink="false">http://www.imabit.com/?p=386</guid>

					<description><![CDATA[Versión en español de esta publicación. This tutorial explains how to install CUDA 7.0 Production Release in a Debian Wheezy system, the first thing we have to do is to download the graphics driver from Nvidia website and select the current model of the graphics card we have, in my case I have a server&#8230;&#160;<a href="https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-0-in-debian-wheezy/" class="" rel="bookmark">Read More &#187;<span class="screen-reader-text">Installing Nvidia Drivers and CUDA 7.0 in Debian Wheezy</span></a>]]></description>
										<content:encoded><![CDATA[<p><a href="https://www.hasdid.com/2015/03/instalando-drivers-de-nvidia-y-cuda-7-0-en-debian-wheezy/" target="_blank">Versión en español de esta publicación.</a><br />
This tutorial explains how to install CUDA 7.0 Production Release in a Debian Wheezy system, the first thing we have to do is to download the graphics driver from Nvidia website and select the current model of the graphics card we have, in my case I have a server with 2 Nvidia cards the first one is a GeForce GTX660 and the second one is a GeForce GTX650, if you&#8217;re not sure of which driver version you should install, you can check the driver versions and models in the following link<span id="more-386"></span></p>
<p><a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a></p>
<p>The required driver version that supports the new CUDA 7.0 features is 346 or above, please make sure to download the latest version of your card driver</p>
<p>Also we need to download the CUDA toolkit 7.0 from the following link</p>
<p><a href="https://developer.nvidia.com/cuda-toolkit" target="_blank">https://developer.nvidia.com/cuda-toolkit</a></p>
<p>The installer file of the toolkit we need to download is the Linux <strong>RUN</strong> file for Ubuntu, the file name is: <em>cuda_7.0.28_linux.run</em> and the direct link is the following </p>
<p><a href="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run" title="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run" target="_blank">http://developer.download.nvidia.com/compute/cuda/7_0/Prod/local_installers/cuda_7.0.28_linux.run</a></p>
<p>Now we need to verify that we have a CUDA capable GPU by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify we have a cuda capable gpu
lspci | grep -i nvidia
</pre>
<p>In my case the output is something like this</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# lscpi output
03:00.0 VGA compatible controller: NVIDIA Corporation Device 11c0 (rev a1)
03:00.1 Audio device: NVIDIA Corporation Device 0e0b (rev a1)
04:00.0 VGA compatible controller: NVIDIA Corporation Device 0fc6 (rev a1)
04:00.1 Audio device: NVIDIA Corporation Device 0e1b (rev a1)
</pre>
<p>If you don&#8217;t get any output you should verify that your hardware is correctly installed, next we proceed to verify our Linux version by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# Linux version
uname -m &amp;&amp; cat /etc/*release
</pre>
<p>For this post I&#8217;m using a Debian Wheezy installation so you should see something like this</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# version output
x86_64
PRETTY_NAME=&quot;Debian GNU/Linux 7 (wheezy)&quot;
NAME=&quot;Debian GNU/Linux&quot;
VERSION_ID=&quot;7&quot;
VERSION=&quot;7 (wheezy)&quot;
ID=debian
ANSI_COLOR=&quot;1;31&quot;
HOME_URL=&quot;http://www.debian.org/&quot;
SUPPORT_URL=&quot;http://www.debian.org/support/&quot;
BUG_REPORT_URL=&quot;http://bugs.debian.org/&quot;
</pre>
<p>Now we need to verify that we have a valid GCC compiler, this is required in order to install the Nvidia driver, we check it by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify gcc version 
gcc --version
</pre>
<p>And you should see an output like this</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# gcc output
gcc (Debian 4.7.2-5) 4.7.2
Copyright (C) 2012 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
</pre>
<p>If you don&#8217;t have a valid GCC compiler installed please install it by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# gcc install
sudo apt-get install build-essential
</pre>
<p>Before we proceed with the actual installation process we need to uninstall any version of CUDA we had installed previously, if this is the first time you install CUDA please skip this step, we uninstall previous installations by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda uninstall
sudo /usr/local/cuda-X.Y/bin/uninstall_cuda_X.Y.pl
</pre>
<p>Where X and Y is the cuda version</p>
<p>If we are upgrading the Nvidia driver we don&#8217;t have to do anything just because the installer itself removes old driver versions</p>
<p>If we want to uninstall the CUDA driver just run the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# cuda driver uninstall
sudo /usr/bin/nvidia-uninstall
</pre>
<p>Once we have completed the steps above and have downloaded the files needed for the installation we proceed to disable the nouveau driver which is the default driver for Debian, we do that by creating a new file: </p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# edit debian driver configuration file
vim /etc/modprobe.d/disable-nouveau.conf 
</pre>
<p>And add the following content to it</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# blacklist defualt driver
blacklist nouveau
options nouveau modeset=0
</pre>
<p>Note: to verify that we have the nouveau driver running, just run the following command, if it outputs something it means that we actually have a nouveau driver running</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# verify noveau
lsmod | grep nouveau
</pre>
<p>After having the file for blocking the default driver in place, we proceed to restart the machine in <em>default</em> mode,</p>
<p>Once restarted we are going to note that the screen resolution got at a lower level and that means that the default driver was not loaded, then we need to get some header files from our repository to build the Nvidia driver, we do this by executing the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# dependencies
sudo apt-get install linux-headers-$(uname -r)
</pre>
<p>After installing this files we proceed to remove the nouveau driver completely from our system by executing the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# remove the nouveau driver completly
apt-get remove --purge xserver-xorg-video-nouveau
</pre>
<p>After the removal of the driver has happened we need to restart our system in <strong>recovery</strong> mode, once restarted in recovery mode and having the nice console interface we proceed with the driver installation process, first we need to know which version of the compiler was used to compile the current system kernel, this because the system needs to compile the Nvidia driver, if we don&#8217;t know which version was used and which kernel we have, we can find that out by running the following command</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# find curr gcc version
cat /proc/version
</pre>
<p>And we get something like this</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# version output
Linux version 3.2.0-4-amd64 (debian-kernel@lists.debian.org) (gcc version 4.6.3 (Debian 4.6.3-14) ) #1 SMP Debian 3.2.54-2
</pre>
<p>Once we know the correct compiler version, we need to set it up with an export like this</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# set gcc version
export CC=gcc-4.6
</pre>
<p>Now we can proceed with the driver installation, we navigate to our download path and execute the driver</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute driver install
sudo sh NVIDIA-Linux-x86_64-346.47.run
</pre>
<p>Once the installation is finished we proceed to reboot the machine and we&#8217;re going to note that we have a nice screen resolution and our new Nvidia drivers installed, next we proceed with the toolkit installation like this.</p>
<p><b>cuda7_install.sh</b></p>
<pre class="brush: bash; title: ; notranslate">
# execute toolkit install
sudo sh cuda_7.0.28_linux.run
</pre>
<p>When prompted we need to select <strong>not</strong> to install the Nvidia driver since we already installed it, and choose the default path for the samples (recommended) </p>
<p>The last thing to do is to compile the samples and run them, to do this we navigate to the samples directory that we choose and just execute a <strong>make</strong> command</p>
<p>And that&#8217;s it!</p>
<p><strong>Here are some useful links related to CUDA 7.0</strong></p>
<p>The CUDA getting started manual which covers in deep installation instructions<br />
<a href="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf" title="http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf" target="_blank">http://developer.download.nvidia.com/compute/cuda/7_0/Prod/doc/CUDA_Getting_Started_Linux.pdf</a> </p>
<p>The CUDA downloads page<br />
<a href="https://developer.nvidia.com/cuda-downloads" title="https://developer.nvidia.com/cuda-downloads" target="_blank">https://developer.nvidia.com/cuda-downloads</a></p>
<p>The Nvidia Driver downloads page<br />
<a href="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" title="http://www.nvidia.com.mx/Download/index.aspx?lang=en-us" target="_blank">http://www.nvidia.com.mx/Download/index.aspx?lang=en-us</a></p>
<p>A couple of nice blog posts of the CUDA 7.0 features<br />
<a href="http://devblogs.nvidia.com/parallelforall/power-cpp11-cuda-7/" title="http://devblogs.nvidia.com/parallelforall/power-cpp11-cuda-7/" target="_blank">http://devblogs.nvidia.com/parallelforall/power-cpp11-cuda-7/</a><br />
<a href="http://devblogs.nvidia.com/parallelforall/cuda-7-release-candidate-feature-overview/" title="http://devblogs.nvidia.com/parallelforall/cuda-7-release-candidate-feature-overview/" target="_blank">http://devblogs.nvidia.com/parallelforall/cuda-7-release-candidate-feature-overview/</a></p>
<p>Have Fun! <img src="https://s.w.org/images/core/emoji/13.1.0/72x72/1f642.png" alt="🙂" class="wp-smiley" style="height: 1em; max-height: 1em;" /><br />
-Yohan</p>
]]></content:encoded>
					
					<wfw:commentRss>https://www.imabit.com/2016/10/installing-nvidia-drivers-and-cuda-7-0-in-debian-wheezy/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
