<?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>ELL &#8211; 编码无悔 /  Intent &amp; Focused</title>
	<atom:link href="https://www.codelast.com/tag/ell/feed/" rel="self" type="application/rss+xml" />
	<link>https://www.codelast.com</link>
	<description>最优化之路</description>
	<lastBuildDate>Mon, 27 Apr 2020 17:55:57 +0000</lastBuildDate>
	<language>zh-Hans</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.9.4</generator>
	<item>
		<title>[原创] 执行ELL的demo程序cntkDemo.py时程序僵死的问题</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a7%e8%a1%8cell%e7%9a%84demo%e7%a8%8b%e5%ba%8fcntkdemo-py%e6%97%b6%e7%a8%8b%e5%ba%8f%e5%83%b5%e6%ad%bb%e7%9a%84%e9%97%ae%e9%a2%98/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a7%e8%a1%8cell%e7%9a%84demo%e7%a8%8b%e5%ba%8fcntkdemo-py%e6%97%b6%e7%a8%8b%e5%ba%8f%e5%83%b5%e6%ad%bb%e7%9a%84%e9%97%ae%e9%a2%98/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Thu, 20 Jul 2017 17:38:28 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[cntkDemo.py]]></category>
		<category><![CDATA[ELL]]></category>
		<category><![CDATA[Embedded Learning Library]]></category>
		<category><![CDATA[僵死]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9594</guid>

					<description><![CDATA[<p>
OS：Ubuntu 14.04</p>
<p>在台式机上执行ELL的demo程序&#160;cntkDemo.py 时，可能会遇到程序僵死的问题。<br />
cntkDemo.py 这个程序会调用OpenCV，在一个GUI窗口中显示USB摄像头拍摄的实时视频流，而僵死的现象正是：执行到弹出GUI窗口显示摄像头拍摄的视频流的代码的时候，程序进入僵死状态，不能执行后续逻辑。此时，只能Ctrl+C终止掉程序。<br />
<span id="more-9594"></span><br />
我的Ubuntu 14.04是一台老爷机，性能非常差，我觉得这有可能程序僵死的原因之一？我试了几次都是这样，于是我打算换一个思路来跑这个demo，不再纠结于解决窗口僵死的问题。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
先来看一下原版的 cntkDemo.py 部分代码：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &#34;Lucida Console&#34;, &#34;DejaVu Sans Mono&#34;, Monaco, &#34;Courier New&#34;, monospace; background: rgb(0, 34, 64); color: rgb(255, 255, 255);">
    <span style="color: rgb(255, 157, 0);">while</span> (<span style="color: rgb(255, 98, 140);">True</span>):
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Grab next frame</span>
        ret, frame <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">cap.read<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Prepare the image to send to the model.</span>
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> This involves scaling to the required input dimension and re-ordering from BGR to RGB</span>
        data <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">helper.prepare_image_for_predictor</span></pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a7%e8%a1%8cell%e7%9a%84demo%e7%a8%8b%e5%ba%8fcntkdemo-py%e6%97%b6%e7%a8%8b%e5%ba%8f%e5%83%b5%e6%ad%bb%e7%9a%84%e9%97%ae%e9%a2%98/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
OS：Ubuntu 14.04</p>
<p>在台式机上执行ELL的demo程序&nbsp;cntkDemo.py 时，可能会遇到程序僵死的问题。<br />
cntkDemo.py 这个程序会调用OpenCV，在一个GUI窗口中显示USB摄像头拍摄的实时视频流，而僵死的现象正是：执行到弹出GUI窗口显示摄像头拍摄的视频流的代码的时候，程序进入僵死状态，不能执行后续逻辑。此时，只能Ctrl+C终止掉程序。<br />
<span id="more-9594"></span><br />
我的Ubuntu 14.04是一台老爷机，性能非常差，我觉得这有可能程序僵死的原因之一？我试了几次都是这样，于是我打算换一个思路来跑这个demo，不再纠结于解决窗口僵死的问题。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
先来看一下原版的 cntkDemo.py 部分代码：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(0, 34, 64); color: rgb(255, 255, 255);">
    <span style="color: rgb(255, 157, 0);">while</span> (<span style="color: rgb(255, 98, 140);">True</span>):
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Grab next frame</span>
        ret, frame <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">cap.read<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Prepare the image to send to the model.</span>
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> This involves scaling to the required input dimension and re-ordering from BGR to RGB</span>
        data <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">helper.prepare_image_for_predictor<span style="color: rgb(225, 239, 255);">(</span>frame<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Get the model to classify the image, by returning a list of probabilities for the classes it can detect</span>
        predictions <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">model.Predict<span style="color: rgb(225, 239, 255);">(</span>data<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Get the (at most) top 5 predictions that meet our threshold. This is returned as a list of tuples,</span>
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> each with the text label and the prediction score.</span>
        top5 <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">helper.get_top_n<span style="color: rgb(225, 239, 255);">(</span>predictions, <span style="color: rgb(255, 98, 140);">5</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Turn the top5 into a text string to display</span>
        text <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(58, 217, 0);">&quot;</span><span style="color: rgb(58, 217, 0);">&quot;</span>.<span style="color: rgb(255, 238, 128);">join<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(128, 255, 187);">str</span><span style="color: rgb(225, 239, 255);">(</span>element<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">0</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(58, 217, 0);">&quot;</span>(<span style="color: rgb(58, 217, 0);">&quot;</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(128, 255, 187);">str</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(128, 255, 187);">int</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(255, 98, 140);">100</span><span style="color: rgb(255, 157, 0);">*</span>element<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">1</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span><span style="color: rgb(225, 239, 255);">)</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(58, 217, 0);">&quot;</span>%)  <span style="color: rgb(58, 217, 0);">&quot;</span> <span style="color: rgb(255, 157, 0);">for</span> element <span style="color: rgb(255, 157, 0);">in</span> top5<span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Draw the text on the frame</span>
        frameToShow <span style="color: rgb(255, 157, 0);">=</span> frame
        <span style="color: rgb(255, 238, 128);">helper.draw_label<span style="color: rgb(225, 239, 255);">(</span>frameToShow, text<span style="color: rgb(225, 239, 255);">)</span></span>
        <span style="color: rgb(255, 238, 128);">helper.draw_fps<span style="color: rgb(225, 239, 255);">(</span>frameToShow<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Show the new frame</span>
        <span style="color: rgb(255, 238, 128);">cv2.imshow<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(58, 217, 0);">&#39;</span>frame<span style="color: rgb(58, 217, 0);">&#39;</span>, frameToShow<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Wait for Esc key</span>
        <span style="color: rgb(255, 157, 0);">if</span> <span style="color: rgb(255, 238, 128);">cv2.waitKey<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(255, 98, 140);">1</span><span style="color: rgb(225, 239, 255);">)</span></span> <span style="color: rgb(255, 157, 0);">&amp;</span> <span style="color: rgb(255, 98, 140);">0xFF</span> <span style="color: rgb(255, 157, 0);">==</span> <span style="color: rgb(255, 98, 140);">27</span>:
            <span style="color: rgb(255, 157, 0);">break</span></pre>
<p>
这段代码的注释非常清晰，它的功能是：在一个无限循环中，不断地去抓取USB摄像头拍摄的一帧图像，然后用model预测其分类及概率，最后再把预测结果叠加显示在GUI窗口中，类似于下面这样：<br />
<img decoding="async" alt="ELL coffee mug" src="https://www.codelast.com/wp-content/uploads/2020/04/ell_coffee_mug.jpg" style="width: 500px; height: 399px;" /><br />
既然 cntkDemo.py 主要是为了测试model能不能正常跑，那么我在命令行以文字形式显示预测结果也是一样的啊，没有必要非得在GUI窗口中展示。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
于是我把程序改成了下面这样（完整程序）：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(0, 34, 64); color: rgb(255, 255, 255);">
<span style="color: rgb(255, 157, 0);">import</span> sys
<span style="color: rgb(255, 157, 0);">import</span> os
<span style="color: rgb(255, 157, 0);">import</span> numpy <span style="color: rgb(255, 157, 0);">as</span> np
<span style="color: rgb(255, 157, 0);">import</span> cv2
<span style="color: rgb(255, 157, 0);">import</span> time

<span style="color: rgb(255, 157, 0);">import</span> findEll
<span style="color: rgb(255, 157, 0);">import</span> cntk_to_ell
<span style="color: rgb(255, 157, 0);">import</span> modelHelper <span style="color: rgb(255, 157, 0);">as</span> mh

<span style="color: rgb(255, 238, 128);">def</span> <span style="color: rgb(255, 221, 0);">get_ell_predictor</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(204, 204, 204);">modelConfig</span><span style="color: rgb(225, 239, 255);">)</span><span style="color: rgb(225, 239, 255);">:</span>
    <span style="color: rgb(58, 217, 0);">&quot;&quot;&quot;</span>Imports a model and returns an ELL.Predictor.<span style="color: rgb(58, 217, 0);">&quot;&quot;&quot;</span>
    <span style="color: rgb(255, 157, 0);">return</span> <span style="color: rgb(255, 238, 128);">cntk_to_ell.predictor_from_cntk_model<span style="color: rgb(225, 239, 255);">(</span>modelConfig.model_files<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">0</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span></span>

<span style="color: rgb(255, 238, 128);">def</span> <span style="color: rgb(255, 221, 0);">main</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">)</span><span style="color: rgb(225, 239, 255);">:</span>

    <span style="color: rgb(255, 157, 0);">if</span> (<span style="color: rgb(255, 157, 0);">not</span> <span style="color: rgb(255, 238, 128);">os.path.exists<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(58, 217, 0);">&#39;</span>VGG16_ImageNet_Caffe.model<span style="color: rgb(58, 217, 0);">&#39;</span><span style="color: rgb(225, 239, 255);">)</span></span>):
        <span style="color: rgb(255, 157, 0);">print</span>(<span style="color: rgb(58, 217, 0);">&quot;</span>Please download the &#39;VGG16_ImageNet_Caffe.model&#39; file, see README.md<span style="color: rgb(58, 217, 0);">&quot;</span>)
        <span style="color: rgb(255, 238, 128);">sys.exit<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(255, 98, 140);">1</span><span style="color: rgb(225, 239, 255);">)</span></span>
        
    <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> ModelConfig for VGG16 model from CNTK Model Gallery</span>
    <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Follow the instructions in README.md to download the model if you intend to use it.</span>
    helper <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">mh.ModelHelper<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(58, 217, 0);">&quot;</span>VGG16ImageNet<span style="color: rgb(58, 217, 0);">&quot;</span>, <span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(58, 217, 0);">&quot;</span>VGG16_ImageNet_Caffe.model<span style="color: rgb(58, 217, 0);">&quot;</span><span style="color: rgb(225, 239, 255);">]</span>, <span style="color: rgb(58, 217, 0);">&quot;</span>cntkVgg16ImageNetLabels.txt<span style="color: rgb(58, 217, 0);">&quot;</span>, <span style="color: rgb(204, 204, 204);">scaleFactor</span><span style="color: rgb(255, 157, 0);">=</span><span style="color: rgb(255, 98, 140);">1.0</span><span style="color: rgb(225, 239, 255);">)</span></span>

    <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Import the model</span>
    model <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">get_ell_predictor<span style="color: rgb(225, 239, 255);">(</span>helper<span style="color: rgb(225, 239, 255);">)</span></span>

    <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Save the model</span>
    <span style="color: rgb(255, 238, 128);">helper.save_ell_predictor_to_file<span style="color: rgb(225, 239, 255);">(</span>model, <span style="color: rgb(58, 217, 0);">&quot;</span>vgg16ImageNet.map<span style="color: rgb(58, 217, 0);">&quot;</span><span style="color: rgb(225, 239, 255);">)</span></span>

    camera <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 98, 140);">0</span>
    <span style="color: rgb(255, 157, 0);">if</span> (<span style="color: rgb(255, 238, 128);"><span style="color: rgb(255, 176, 84);">len</span><span style="color: rgb(225, 239, 255);">(</span>sys.argv<span style="color: rgb(225, 239, 255);">)</span></span> <span style="color: rgb(255, 157, 0);">&gt;</span> <span style="color: rgb(255, 98, 140);">1</span>):
        camera <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);"><span style="color: rgb(128, 255, 187);">int</span><span style="color: rgb(225, 239, 255);">(</span>sys.argv<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">1</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span></span> 

    <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Start video capture device</span>
    cap <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">cv2.VideoCapture<span style="color: rgb(225, 239, 255);">(</span>camera<span style="color: rgb(225, 239, 255);">)</span></span>

    <span style="color: rgb(255, 157, 0);">while</span> (<span style="color: rgb(255, 98, 140);">True</span>):
        <span style="color: rgb(255, 157, 0);">print</span>(<span style="color: rgb(58, 217, 0);">&#39;</span>Read a frame from camera...<span style="color: rgb(58, 217, 0);">&#39;</span>)
        ret, frame <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">cap.read<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Prepare the image to send to the model.</span>
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> This involves scaling to the required input dimension and re-ordering from BGR to RGB</span>
        data <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">helper.prepare_image_for_predictor<span style="color: rgb(225, 239, 255);">(</span>frame<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Get the model to classify the image, by returning a list of probabilities for the classes it can detect</span>
        predictions <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">model.Predict<span style="color: rgb(225, 239, 255);">(</span>data<span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Get the (at most) top 5 predictions that meet our threshold. This is returned as a list of tuples,</span>
        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> each with the text label and the prediction score.</span>
        top5 <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(255, 238, 128);">helper.get_top_n<span style="color: rgb(225, 239, 255);">(</span>predictions, <span style="color: rgb(255, 98, 140);">5</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Turn the top5 into a text string to display</span>
        text <span style="color: rgb(255, 157, 0);">=</span> <span style="color: rgb(58, 217, 0);">&quot;</span><span style="color: rgb(58, 217, 0);">&quot;</span>.<span style="color: rgb(255, 238, 128);">join<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(128, 255, 187);">str</span><span style="color: rgb(225, 239, 255);">(</span>element<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">0</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(58, 217, 0);">&quot;</span>(<span style="color: rgb(58, 217, 0);">&quot;</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(128, 255, 187);">str</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(128, 255, 187);">int</span><span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(255, 98, 140);">100</span><span style="color: rgb(255, 157, 0);">*</span>element<span style="color: rgb(225, 239, 255);">[</span><span style="color: rgb(255, 98, 140);">1</span><span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span><span style="color: rgb(225, 239, 255);">)</span> <span style="color: rgb(255, 157, 0);">+</span> <span style="color: rgb(58, 217, 0);">&quot;</span>%)  <span style="color: rgb(58, 217, 0);">&quot;</span> <span style="color: rgb(255, 157, 0);">for</span> element <span style="color: rgb(255, 157, 0);">in</span> top5<span style="color: rgb(225, 239, 255);">]</span><span style="color: rgb(225, 239, 255);">)</span></span>

        <span style="color: rgb(0, 136, 255); font-style: italic;"><span style="color: rgb(225, 239, 255);">#</span> Output the text on command line</span>
        <span style="color: rgb(255, 157, 0);">print</span>(text)

<span style="color: rgb(255, 157, 0);">if</span> <span style="color: rgb(128, 255, 187);">__name__</span> <span style="color: rgb(255, 157, 0);">==</span> <span style="color: rgb(58, 217, 0);">&quot;</span>__main__<span style="color: rgb(58, 217, 0);">&quot;</span>:
    <span style="color: rgb(255, 238, 128);">main<span style="color: rgb(225, 239, 255);">(</span><span style="color: rgb(225, 239, 255);">)</span></span></pre>
<p>
其中最关键的是，不再用&nbsp;cv2.imshow() 的方式来弹出GUI窗口，而是用 print(text) 的方式把结果打印到command line。<br />
经过实测，在我的老爷机上这个程序就完全不会僵死了。此时，你把摄像头对准哪个物体，它拍摄的就是哪个物体的图像，model也就是对这个物体的图像进行分类预测。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
下面是我的一次test的command line输出：</p>
<blockquote>
<div>
		OpenBLAS : Your OS does not support AVX instructions. OpenBLAS is using Nehalem kernels as a fallback, which may give poorer performance.</div>
<div>
		Read a frame from camera, time 1</div>
<div>
		Frame 1 saved to disk</div>
<div>
		Read a frame from camera, time 2</div>
<div>
		Frame 2 saved to disk</div>
<div>
		Read a frame from camera, time 3</div>
<div>
		Frame 3 saved to disk</div>
<div>
		Read a frame from camera, time 4</div>
<div>
		Frame 4 saved to disk</div>
<div>
		Read a frame from camera, time 5</div>
<div>
		Frame 5 saved to disk</div>
<div>
		Loading...</div>
<div>
		Selected CPU as the process wide default device.</div>
<div>
		&nbsp;</div>
<div>
		Finished loading.</div>
<div>
		Pre-processing...</div>
<div>
		&nbsp;</div>
<div>
		Will not process Dropout - skipping this layer as irrelevant.</div>
<div>
		&nbsp;</div>
<div>
		Will not process Dropout - skipping this layer as irrelevant.</div>
<div>
		&nbsp;</div>
<div>
		Will not process Combine - skipping this layer as irrelevant.</div>
<div>
		Convolution : &nbsp;226x226x3 &nbsp;-&gt; &nbsp;224x224x64 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;224x224x64 &nbsp;-&gt; &nbsp;226x226x64 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;226x226x64 &nbsp;-&gt; &nbsp;224x224x64 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;224x224x64 &nbsp;-&gt; &nbsp;224x224x64 | padding &nbsp;0</div>
<div>
		Pooling : &nbsp;224x224x64 &nbsp;-&gt; &nbsp;114x114x64 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;114x114x64 &nbsp;-&gt; &nbsp;112x112x128 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;112x112x128 &nbsp;-&gt; &nbsp;114x114x128 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;114x114x128 &nbsp;-&gt; &nbsp;112x112x128 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;112x112x128 &nbsp;-&gt; &nbsp;112x112x128 | padding &nbsp;0</div>
<div>
		Pooling : &nbsp;112x112x128 &nbsp;-&gt; &nbsp;58x58x128 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;58x58x128 &nbsp;-&gt; &nbsp;56x56x256 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;56x56x256 &nbsp;-&gt; &nbsp;58x58x256 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;58x58x256 &nbsp;-&gt; &nbsp;56x56x256 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;56x56x256 &nbsp;-&gt; &nbsp;58x58x256 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;58x58x256 &nbsp;-&gt; &nbsp;56x56x256 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;56x56x256 &nbsp;-&gt; &nbsp;56x56x256 | padding &nbsp;0</div>
<div>
		Pooling : &nbsp;56x56x256 &nbsp;-&gt; &nbsp;30x30x256 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;30x30x256 &nbsp;-&gt; &nbsp;28x28x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;28x28x512 &nbsp;-&gt; &nbsp;30x30x512 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;30x30x512 &nbsp;-&gt; &nbsp;28x28x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;28x28x512 &nbsp;-&gt; &nbsp;30x30x512 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;30x30x512 &nbsp;-&gt; &nbsp;28x28x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;28x28x512 &nbsp;-&gt; &nbsp;28x28x512 | padding &nbsp;0</div>
<div>
		Pooling : &nbsp;28x28x512 &nbsp;-&gt; &nbsp;16x16x512 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;16x16x512 &nbsp;-&gt; &nbsp;14x14x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;14x14x512 &nbsp;-&gt; &nbsp;16x16x512 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;16x16x512 &nbsp;-&gt; &nbsp;14x14x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;14x14x512 &nbsp;-&gt; &nbsp;16x16x512 | padding &nbsp;0</div>
<div>
		Convolution : &nbsp;16x16x512 &nbsp;-&gt; &nbsp;14x14x512 | padding &nbsp;1</div>
<div>
		ReLU : &nbsp;14x14x512 &nbsp;-&gt; &nbsp;14x14x512 | padding &nbsp;0</div>
<div>
		Pooling : &nbsp;14x14x512 &nbsp;-&gt; &nbsp;7x7x512 | padding &nbsp;0</div>
<div>
		linear : &nbsp;7x7x512 &nbsp;-&gt; &nbsp;1x1x4096 | padding &nbsp;0</div>
<div>
		ReLU : &nbsp;1x1x4096 &nbsp;-&gt; &nbsp;1x1x4096 | padding &nbsp;0</div>
<div>
		linear : &nbsp;1x1x4096 &nbsp;-&gt; &nbsp;1x1x4096 | padding &nbsp;0</div>
<div>
		ReLU : &nbsp;1x1x4096 &nbsp;-&gt; &nbsp;1x1x4096 | padding &nbsp;0</div>
<div>
		linear : &nbsp;1x1x4096 &nbsp;-&gt; &nbsp;1x1x1000 | padding &nbsp;0</div>
<div>
		Softmax : &nbsp;1x1x1000 &nbsp;-&gt; &nbsp;1x1x1000 | padding &nbsp;0</div>
<div>
		&nbsp;</div>
<div>
		Finished pre-processing.</div>
<div>
		&nbsp;</div>
<div>
		Constructing equivalent ELL layers from CNTK...</div>
<div>
		Converting layer &nbsp;conv1_1: Convolution(data: Tensor[3,224,224]) -&gt; Tensor[64,224,224]</div>
<div>
		Converting layer &nbsp;relu1_1: ReLU(conv1_1: Tensor[64,224,224]) -&gt; Tensor[64,224,224]</div>
<div>
		Converting layer &nbsp;conv1_2: Convolution(relu1_1: Tensor[64,224,224]) -&gt; Tensor[64,224,224]</div>
<div>
		Converting layer &nbsp;relu1_2: ReLU(conv1_2: Tensor[64,224,224]) -&gt; Tensor[64,224,224]</div>
<div>
		Converting layer &nbsp;pool1: Pooling(relu1_2: Tensor[64,224,224]) -&gt; Tensor[64,112,112]</div>
<div>
		Converting layer &nbsp;conv2_1: Convolution(pool1: Tensor[64,112,112]) -&gt; Tensor[128,112,112]</div>
<div>
		Converting layer &nbsp;relu2_1: ReLU(conv2_1: Tensor[128,112,112]) -&gt; Tensor[128,112,112]</div>
<div>
		Converting layer &nbsp;conv2_2: Convolution(relu2_1: Tensor[128,112,112]) -&gt; Tensor[128,112,112]</div>
<div>
		Converting layer &nbsp;relu2_2: ReLU(conv2_2: Tensor[128,112,112]) -&gt; Tensor[128,112,112]</div>
<div>
		Converting layer &nbsp;pool2: Pooling(relu2_2: Tensor[128,112,112]) -&gt; Tensor[128,56,56]</div>
<div>
		Converting layer &nbsp;conv3_1: Convolution(pool2: Tensor[128,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;relu3_1: ReLU(conv3_1: Tensor[256,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;conv3_2: Convolution(relu3_1: Tensor[256,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;relu3_2: ReLU(conv3_2: Tensor[256,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;conv3_3: Convolution(relu3_2: Tensor[256,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;relu3_3: ReLU(conv3_3: Tensor[256,56,56]) -&gt; Tensor[256,56,56]</div>
<div>
		Converting layer &nbsp;pool3: Pooling(relu3_3: Tensor[256,56,56]) -&gt; Tensor[256,28,28]</div>
<div>
		Converting layer &nbsp;conv4_1: Convolution(pool3: Tensor[256,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;relu4_1: ReLU(conv4_1: Tensor[512,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;conv4_2: Convolution(relu4_1: Tensor[512,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;relu4_2: ReLU(conv4_2: Tensor[512,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;conv4_3: Convolution(relu4_2: Tensor[512,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;relu4_3: ReLU(conv4_3: Tensor[512,28,28]) -&gt; Tensor[512,28,28]</div>
<div>
		Converting layer &nbsp;pool4: Pooling(relu4_3: Tensor[512,28,28]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;conv5_1: Convolution(pool4: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;relu5_1: ReLU(conv5_1: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;conv5_2: Convolution(relu5_1: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;relu5_2: ReLU(conv5_2: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;conv5_3: Convolution(relu5_2: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;relu5_3: ReLU(conv5_3: Tensor[512,14,14]) -&gt; Tensor[512,14,14]</div>
<div>
		Converting layer &nbsp;pool5: Pooling(relu5_3: Tensor[512,14,14]) -&gt; Tensor[512,7,7]</div>
<div>
		Converting layer &nbsp;fc6: linear(pool5: Tensor[512,7,7]) -&gt; Tensor[4096]</div>
<div>
		Converting layer &nbsp;relu6: ReLU(fc6: Tensor[4096]) -&gt; Tensor[4096]</div>
<div>
		Converting layer &nbsp;fc7: linear(drop6: Tensor[4096]) -&gt; Tensor[4096]</div>
<div>
		Converting layer &nbsp;relu7: ReLU(fc7: Tensor[4096]) -&gt; Tensor[4096]</div>
<div>
		Converting layer &nbsp;fc8: linear(drop7: Tensor[4096]) -&gt; Tensor[1000]</div>
<div>
		Converting layer &nbsp;prob: Softmax(fc8: Tensor[1000]) -&gt; Tensor[1000]</div>
<div>
		&nbsp;</div>
<div>
		...Finished constructing ELL layers.</div>
<div>
		lighter, light, igniter, ignitor(28%) &nbsp;</div>
<div>
		lighter, light, igniter, ignitor(28%) &nbsp;</div>
<div>
		&nbsp;</div>
<div>
		lighter, light, igniter, ignitor(32%) &nbsp;</div>
<div>
		lighter, light, igniter, ignitor(30%)</div>
<div>
		......</div>
</blockquote>
<div>
	有人可能会说这样做不直观，根本无法肯定摄像头当前正在拍摄的是什么东西。如果你非要看图片的话，倒是有一个折中的办法，就是用&nbsp;<span style="color:#0000ff;">cv2.imwrite(&#39;/home/codelast/current.jpg&#39;, frame)</span> 把抓取的一帧图像保存到磁盘上，然后自己去打开文件看吧。</p>
<p>	最后不得不感叹一下，我的台式机真的是太老了，跑这个demo真的很慢，没有个5分钟以上是根本没可能到开始预测的步骤的。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e6%89%a7%e8%a1%8cell%e7%9a%84demo%e7%a8%8b%e5%ba%8fcntkdemo-py%e6%97%b6%e7%a8%8b%e5%ba%8f%e5%83%b5%e6%ad%bb%e7%9a%84%e9%97%ae%e9%a2%98/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 解决ELL demo的 OpenCV Error: Unspecified error in cvShowImage 错误</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3ell-demo%e7%9a%84-opencv-error-unspecified-error-in-cvshowimage-%e9%94%99%e8%af%af/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3ell-demo%e7%9a%84-opencv-error-unspecified-error-in-cvshowimage-%e9%94%99%e8%af%af/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Mon, 17 Jul 2017 16:17:36 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[ELL]]></category>
		<category><![CDATA[libgtk2.0-dev]]></category>
		<category><![CDATA[OpenCV]]></category>
		<category><![CDATA[Unspecified error in cvShowImage]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9473</guid>

					<description><![CDATA[<p>
OS：Ubuntu 14.04 LTS</p>
<p>在<a href="https://github.com/Microsoft/ELL" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">ELL</span></a>的<a href="https://github.com/Microsoft/ELL/blob/master/tutorials/vision/gettingStarted/cntk.md" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">tutorial</span></a>中，有一个步骤是在PC上测试运行一个demo程序来检查ELL能否正常工作，当你选择CNTK model的时候，运行的就是 <span style="color:#0000ff;">cntkDemo.py</span> 这个demo程序。<br />
<span id="more-9473"></span><br />
这个demo程序调用了OpenCV来在GUI窗口中显示摄像头拍摄的实时视频，可能会跑不起来，并输出下面这样的错误：</p>
<blockquote>
<p>
		OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /feedstock_root/build_artefacts/opencv_1490907195496/work/opencv-3.2.0/modules/highgui/src/window.cpp,</p></blockquote>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3ell-demo%e7%9a%84-opencv-error-unspecified-error-in-cvshowimage-%e9%94%99%e8%af%af/" class="read-more">Read More </a>]]></description>
										<content:encoded><![CDATA[<p>
OS：Ubuntu 14.04 LTS</p>
<p>在<a href="https://github.com/Microsoft/ELL" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">ELL</span></a>的<a href="https://github.com/Microsoft/ELL/blob/master/tutorials/vision/gettingStarted/cntk.md" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">tutorial</span></a>中，有一个步骤是在PC上测试运行一个demo程序来检查ELL能否正常工作，当你选择CNTK model的时候，运行的就是 <span style="color:#0000ff;">cntkDemo.py</span> 这个demo程序。<br />
<span id="more-9473"></span><br />
这个demo程序调用了OpenCV来在GUI窗口中显示摄像头拍摄的实时视频，可能会跑不起来，并输出下面这样的错误：</p>
<blockquote>
<p>
		OpenCV Error: Unspecified error (The function is not implemented. Rebuild the library with Windows, GTK+ 2.x or Carbon support. If you are on Ubuntu or Debian, install libgtk2.0-dev and pkg-config, then re-run cmake or configure script) in cvShowImage, file /feedstock_root/build_artefacts/opencv_1490907195496/work/opencv-3.2.0/modules/highgui/src/window.cpp, ...（后面还有很长的内容）</p>
</blockquote>
<p>如果你的PC和我的一样老旧，那么执行 <span style="color:#0000ff;">python cntkDemo.py</span> 可能耗时非常长（你可以在一台老爷车上试一下），直到N分钟后才打印出上面的错误，然后程序挂掉，这使得我们解决这个问题非常不方便&mdash;&mdash;每次都要等待超级长的时间，才知道自己的修改是否有效。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
因此，为了能便于debug问题，我们先把和上面那个错误相关的关键代码段提取出来，单独放到一个源代码文件 z.py 中：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="python language-python hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;"><span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">import</span>&nbsp;numpy&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">as</span>&nbsp;np
<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">import</span>&nbsp;cv2
cam&nbsp;=&nbsp;cv2.VideoCapture(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">0</span>)
<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">while</span>&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">True</span>:
&nbsp;&nbsp;&nbsp;&nbsp;ret,&nbsp;frame&nbsp;=&nbsp;cam.read()
&nbsp;&nbsp;&nbsp;&nbsp;cv2.imshow(<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;test&#39;</span>,&nbsp;frame)
&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">if</span>&nbsp;cv2.waitKey(<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>)&nbsp;&amp;&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">0xFF</span>&nbsp;==&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">27</span>:
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<span class="hljs-keyword" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(248, 35, 117); word-wrap: inherit !important; word-break: inherit !important;">break</span></code></pre>
</section>
<p>稍后，我们只需要执行 <span style="color:#0000ff;">python z.py</span>，不出错的话，就说明我们搞定了以上问题。<br />
注意：这里的程序假设你的Ubuntu PC上至少连接了一个USB摄像头，cv2.VideoCapture(0)里的0就是指第一个摄像头，千万不要傻傻地在没有摄像头的情况下测试。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a></p>
<div>
	其实，打印出的错误信息已经告诉我们，如果你使用的是Ubuntu，需要安装&nbsp;<span style="color:#0000ff;">libgtk2.0-dev</span> 和 <span style="color:#0000ff;">pkg-config</span>，然后rebuild软件。这里没有写清楚到底是rebuild OpenCV还是ELL，但我理解应该是指OpenCV。不过根据我的试验，把系统里的OpenCV卸载掉，并且把miniconda环境里的OpenCV也卸载掉，然后安装&nbsp;libgtk2.0-dev 和 pkg-config，再按ELL doc的方法把miniconda环境里的OpenCV装上，并不能fix这个问题。<br />
	经过漫长的Google搜索，我最终找到了问题的原因：ELL文档中提供的安装opencv的方法有问题（至少在我的Ubuntu上如此）：</div>
<blockquote>
<div>
		conda install -c conda-forge opencv</div>
</blockquote>
<div>
	这样安装上的OpenCV，在运行<span style="color:#0000ff;">&nbsp;cntkDemo.py</span> 的时候就会出上面的错。</div>
<div>
	&nbsp;</div>
<div>
	我在Stack Overflow上找到的一个解决方案是，你应该在conda环境下，用下面的方法来安装OpenCV：</div>
<blockquote>
<div>
		conda install --channel loopbio --channel conda-forge --channel pkgw-forge gtk2 ffmpeg ffmpeg-feature gtk2-feature opencv</div>
</blockquote>
<div>
	这样安装好了OpenCV之后，再运行 python z.py，你就会看到它神奇地解决了问题：马上弹出了一个图形窗口，里面显示的就是摄像头拍摄的实时视频。<br />
	当然，在安装之前，如果已经装错了另一个版本的OpenCV，需要先用 <span style="color:#0000ff;">conda remove opencv</span> 卸载掉。关于这个错误的详解可以看<a href="https://stackoverflow.com/questions/40207011/opencv-not-working-properly-with-python-on-linux-with-anaconda-getting-error-th" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">这个</span></a>和<a href="https://github.com/conda-forge/opencv-feedstock/issues/43" rel="noopener noreferrer" target="_blank"><span style="background-color:#ffa07a;">这个</span></a>链接。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3ell-demo%e7%9a%84-opencv-error-unspecified-error-in-cvshowimage-%e9%94%99%e8%af%af/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 解决编译ELL的错误：undefined reference to `cblas_xxx&#039;</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3%e7%bc%96%e8%af%91ell%e7%9a%84%e9%94%99%e8%af%af%ef%bc%9aundefined-reference-to-cblas_xxx/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3%e7%bc%96%e8%af%91ell%e7%9a%84%e9%94%99%e8%af%af%ef%bc%9aundefined-reference-to-cblas_xxx/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sun, 16 Jul 2017 16:17:45 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[ELL]]></category>
		<category><![CDATA[undefined reference to cblas_xxx]]></category>
		<category><![CDATA[编译]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9505</guid>

					<description><![CDATA[<p>
OS：Ubuntu 14.04 LTS<br />
在PC上编译<a href="https://github.com/Microsoft/ELL" rel="noopener noreferrer" target="_blank"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>的时候，尽管你可能已经安装了所有ELL文档中要求的软件依赖，可能还是会遇到 <span style="color:#0000ff;">undefined reference to `cblas_xxx&#39;</span> 的错误，如下：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &#34;Helvetica Neue&#34;, Helvetica, &#34;Hiragino Sans GB&#34;, &#34;Microsoft YaHei&#34;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="python language-python hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">0</span>%]&#160;Built&#160;target&#160;documentation
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">10</span>%]&#160;Built&#160;target&#160;utilities
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">11</span>%]&#160;Built&#160;target&#160;math
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">14</span>%]&#160;Built&#160;target&#160;data
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">23</span>%]&#160;Built&#160;target&#160;emitters
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">24</span>%]&#160;Built&#160;target&#160;evaluators
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">28</span>%]&#160;Built&#160;target&#160;functions
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">37</span>%]&#160;Built&#160;target&#160;model
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">39</span>%]&#160;Built&#160;target&#160;predictors
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">48</span>%]&#160;Built&#160;target&#160;nodes
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">52</span>%]&#160;Built&#160;target&#160;trainers
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">59</span>%]&#160;Built&#160;target&#160;common
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">60</span>%]&#160;Built&#160;target&#160;testing
[&#160;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">61</span>%]&#160;Linking&#160;CXX&#160;executable&#160;common_test
../math/libmath.a(BlasWrapper.cpp.o):&#160;In&#160;function&#160;ell::math::Blas::Copy(int,&#160;float&#160;const*,&#160;int,&#160;float*,&#160;int)</code></pre>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3%e7%bc%96%e8%af%91ell%e7%9a%84%e9%94%99%e8%af%af%ef%bc%9aundefined-reference-to-cblas_xxx/" class="read-more">Read More </a></section>]]></description>
										<content:encoded><![CDATA[<p>
OS：Ubuntu 14.04 LTS<br />
在PC上编译<a href="https://github.com/Microsoft/ELL" rel="noopener noreferrer" target="_blank"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>的时候，尽管你可能已经安装了所有ELL文档中要求的软件依赖，可能还是会遇到 <span style="color:#0000ff;">undefined reference to `cblas_xxx&#39;</span> 的错误，如下：</p>
<section class="output_wrapper" id="output_wrapper_id" style="font-size: 16px; color: rgb(62, 62, 62); line-height: 1.6; letter-spacing: 0px; font-family: &quot;Helvetica Neue&quot;, Helvetica, &quot;Hiragino Sans GB&quot;, &quot;Microsoft YaHei&quot;, Arial, sans-serif;">
<pre style="font-size: inherit; color: inherit; line-height: inherit; margin-top: 0px; margin-bottom: 0px; padding: 0px;">
<code class="python language-python hljs" style="margin: 0px 2px; line-height: 18px; font-size: 14px; letter-spacing: 0px; font-family: Consolas, Inconsolata, Courier, monospace; border-radius: 0px; color: rgb(169, 183, 198); background: rgb(40, 43, 46); padding: 0.5em; overflow-wrap: normal !important; word-break: normal !important; overflow: auto !important; display: -webkit-box !important;">[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">0</span>%]&nbsp;Built&nbsp;target&nbsp;documentation
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">10</span>%]&nbsp;Built&nbsp;target&nbsp;utilities
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">11</span>%]&nbsp;Built&nbsp;target&nbsp;math
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">14</span>%]&nbsp;Built&nbsp;target&nbsp;data
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">23</span>%]&nbsp;Built&nbsp;target&nbsp;emitters
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">24</span>%]&nbsp;Built&nbsp;target&nbsp;evaluators
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">28</span>%]&nbsp;Built&nbsp;target&nbsp;functions
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">37</span>%]&nbsp;Built&nbsp;target&nbsp;model
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">39</span>%]&nbsp;Built&nbsp;target&nbsp;predictors
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">48</span>%]&nbsp;Built&nbsp;target&nbsp;nodes
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">52</span>%]&nbsp;Built&nbsp;target&nbsp;trainers
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">59</span>%]&nbsp;Built&nbsp;target&nbsp;common
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">60</span>%]&nbsp;Built&nbsp;target&nbsp;testing
[&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">61</span>%]&nbsp;Linking&nbsp;CXX&nbsp;executable&nbsp;common_test
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Copy(int,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x31):&nbsp;undefined&nbsp;reference&nbsp;tocblas_scopy&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Copy(int,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x69):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dcopy&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Asum(int,&nbsp;float&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x92):&nbsp;undefined&nbsp;reference&nbsp;tocblas_sasum&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Asum(int,&nbsp;double&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0xba):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dasum&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Nrm2(int,&nbsp;float&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0xf0):&nbsp;undefined&nbsp;reference&nbsp;tocblas_snrm2&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Nrm2(int,&nbsp;double&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x118):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dnrm2&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Scal(int,&nbsp;float,&nbsp;float*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x15b):&nbsp;undefined&nbsp;reference&nbsp;tocblas_sscal&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Scal(int,&nbsp;double,&nbsp;double*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x193):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dscal&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Axpy(int,&nbsp;float,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x1d9):&nbsp;undefined&nbsp;reference&nbsp;tocblas_saxpy&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Axpy(int,&nbsp;double,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x221):&nbsp;undefined&nbsp;reference&nbsp;tocblas_daxpy&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Dot(int,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x259):&nbsp;undefined&nbsp;reference&nbsp;tocblas_sdot&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Dot(int,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double&nbsp;const*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x290):&nbsp;undefined&nbsp;reference&nbsp;tocblas_ddot&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Gemv(CBLAS_ORDER,&nbsp;CBLAS_TRANSPOSE,&nbsp;int,&nbsp;int,&nbsp;float,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float,&nbsp;float*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x309):&nbsp;undefined&nbsp;reference&nbsp;tocblas_sgemv&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Gemv(CBLAS_ORDER,&nbsp;CBLAS_TRANSPOSE,&nbsp;int,&nbsp;int,&nbsp;double,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double,&nbsp;double*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x37c):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dgemv&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Gemm(CBLAS_ORDER,&nbsp;CBLAS_TRANSPOSE,&nbsp;CBLAS_TRANSPOSE,&nbsp;int,&nbsp;int,&nbsp;int,&nbsp;float,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float&nbsp;const*,&nbsp;int,&nbsp;float,&nbsp;float*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x3f5):&nbsp;undefined&nbsp;reference&nbsp;tocblas_sgemm&#39;</span>
../math/libmath.a(BlasWrapper.cpp.o):&nbsp;In&nbsp;function&nbsp;ell::math::Blas::Gemm(CBLAS_ORDER,&nbsp;CBLAS_TRANSPOSE,&nbsp;CBLAS_TRANSPOSE,&nbsp;int,&nbsp;int,&nbsp;int,&nbsp;double,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double&nbsp;const*,&nbsp;int,&nbsp;double,&nbsp;double*,&nbsp;int)<span class="hljs-string" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(238, 220, 112); word-wrap: inherit !important; word-break: inherit !important;">&#39;:&nbsp;BlasWrapper.cpp:(.text+0x471):&nbsp;undefined&nbsp;reference&nbsp;tocblas_dgemm&#39;</span>
collect2:&nbsp;error:&nbsp;ld&nbsp;returned&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>&nbsp;exit&nbsp;status
make[<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">2</span>]:&nbsp;***&nbsp;[libraries/common/common_test]&nbsp;Error&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>
make[<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">1</span>]:&nbsp;***&nbsp;[libraries/common/CMakeFiles/common_test.dir/all]&nbsp;Error&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">2</span>
make:&nbsp;***&nbsp;[all]&nbsp;Error&nbsp;<span class="hljs-number" style="font-size: inherit; line-height: inherit; margin: 0px; padding: 0px; color: rgb(174, 135, 250); word-wrap: inherit !important; word-break: inherit !important;">2</span></code></pre>
</section>
<div>
<span id="more-9505"></span>	<br />
	这个问题是由于我的Ubuntu 14.04同时安装了<span style="color:#0000ff;">blas</span>和<span style="color:#0000ff;">atlas</span>导致的&mdash;&mdash;我真的不记得我是什么时候安装的atlas了。在这种情况下，从make的前一步，也就是cmake的输出信息中，可以看出一些端倪（所以说在cmake的时候一定要仔细检查）：</p>
<blockquote>
<div>
			-- The C compiler identification is GNU 6.3.0</div>
<div>
			-- The CXX compiler identification is GNU 6.3.0</div>
<div>
			-- Check for working C compiler: /usr/bin/cc</div>
<div>
			-- Check for working C compiler: /usr/bin/cc -- works</div>
<div>
			-- Detecting C compiler ABI info</div>
<div>
			-- Detecting C compiler ABI info - done</div>
<div>
			-- Detecting C compile features</div>
<div>
			-- Detecting C compile features - done</div>
<div>
			-- Check for working CXX compiler: /usr/bin/c++</div>
<div>
			-- Check for working CXX compiler: /usr/bin/c++ -- works</div>
<div>
			-- Detecting CXX compiler ABI info</div>
<div>
			-- Detecting CXX compiler ABI info - done</div>
<div>
			-- Detecting CXX compile features</div>
<div>
			-- Detecting CXX compile features - done</div>
<div>
			-- Looking for pthread.h</div>
<div>
			-- Looking for pthread.h - found</div>
<div>
			-- Looking for pthread_create</div>
<div>
			-- Looking for pthread_create - not found</div>
<div>
			-- Looking for pthread_create in pthreads</div>
<div>
			-- Looking for pthread_create in pthreads - not found</div>
<div>
			-- Looking for pthread_create in pthread</div>
<div>
			-- Looking for pthread_create in pthread - found</div>
<div>
			-- Found Threads: TRUE</div>
<div>
			--&nbsp;<span style="color: rgb(255, 0, 0);">Blas libraries: /usr/lib/libf77blas.so;/usr/lib/libatlas.so</span></div>
<div>
			-- Blas linker flags:</div>
<div>
			-- Blas include directories:</div>
<div>
			-- Using BLAS include path: /usr/include</div>
<div>
			--&nbsp;<span style="color: rgb(255, 0, 0);">Using BLAS library: /usr/lib/libf77blas.so;/usr/lib/libatlas.so</span></div>
<div>
			-- Using BLAS DLLs:</div>
<div>
			-- Found PythonInterp: /home/codelast/.miniconda3/bin/python (found version &quot;3.6.1&quot;)</div>
<div>
			-- Found PythonLibs: /home/codelast/.miniconda3/lib/libpython3.6m.so (found version &quot;3.6.1&quot;)</div>
<div>
			-- Found SWIG: /usr/local/bin/swig (found suitable version &quot;3.0.12&quot;, minimum required is &quot;3.0.12&quot;)</div>
<div>
			-- Creating wrappers for python</div>
<div>
			-- Creating wrappers for javascript</div>
<div>
			-- Creating wrappers for xml</div>
<div>
			-- Using python found at: /home/codelast/.miniconda3/bin/python</div>
<div>
			-- Using python libraries found at: /home/codelast/.miniconda3/lib/libpython3.6m.so</div>
<div>
			-- Creating wrappers for python</div>
<div>
			-- Generated target compiled_vgg16ImageNet_host</div>
<div>
			-- Generated target compiled_vgg16ImageNet_pi3</div>
<div>
			-- Generated target compiled_vgg16ImageNet_pi0</div>
<div>
			-- Generated target compiled_darknetReference_host</div>
<div>
			-- Generated target compiled_darknetReference_pi3</div>
<div>
			-- Generated target compiled_darknetReference_pi0</div>
<div>
			-- Configuring done</div>
<div>
			-- Generating done</div>
<div>
			-- Build files have been written to: /home/codelast/programme/pi/ELL/build</div>
</blockquote>
<div>
		上面标红的那两句，表明atlas library会被当作blas library来用，这就会导致后面的编译错误。<br />
		所以，我查找了一下Ubuntu系统中已经安装的atlas package：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(0, 34, 64); color: rgb(255, 255, 255);">
sudo dpkg -l <span style="color: rgb(255, 157, 0);">|</span> grep atlas</pre>
<div>
			输出如下：</div>
<blockquote>
<div>
				ii &nbsp;libatlas-base-dev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; 3.10.1-4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;amd64 &nbsp; &nbsp; &nbsp; &nbsp;Automatically Tuned Linear Algebra Software, generic static</div>
<div>
				ii &nbsp;libatlas-dev &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3.10.1-4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;all &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Automatically Tuned Linear Algebra Software, C header files</div>
<div>
				ii &nbsp;libatlas3-base &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;3.10.1-4 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;amd64 &nbsp; &nbsp; &nbsp; &nbsp;Automatically Tuned Linear Algebra Software, generic shared</div>
</blockquote></div>
</div>
<p>然后把这3个package都卸载掉：</p>
<pre style="margin-top: 0px; margin-bottom: 0px; font-stretch: normal; font-size: 0.9333em; line-height: 1.5em; font-family: Consolas, &quot;Lucida Console&quot;, &quot;DejaVu Sans Mono&quot;, Monaco, &quot;Courier New&quot;, monospace; background: rgb(0, 34, 64); color: rgb(255, 255, 255);">
sudo apt-get remove libatlas-base-dev libatlas-dev ibatlas3-base</pre>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
然后再重新cmake，输出信息如下：</p>
<blockquote>
<div>
		-- The C compiler identification is GNU 6.3.0</div>
<div>
		-- The CXX compiler identification is GNU 6.3.0</div>
<div>
		-- Check for working C compiler: /usr/bin/cc</div>
<div>
		-- Check for working C compiler: /usr/bin/cc -- works</div>
<div>
		-- Detecting C compiler ABI info</div>
<div>
		-- Detecting C compiler ABI info - done</div>
<div>
		-- Detecting C compile features</div>
<div>
		-- Detecting C compile features - done</div>
<div>
		-- Check for working CXX compiler: /usr/bin/c++</div>
<div>
		-- Check for working CXX compiler: /usr/bin/c++ -- works</div>
<div>
		-- Detecting CXX compiler ABI info</div>
<div>
		-- Detecting CXX compiler ABI info - done</div>
<div>
		-- Detecting CXX compile features</div>
<div>
		-- Detecting CXX compile features - done</div>
<div>
		-- Looking for pthread.h</div>
<div>
		-- Looking for pthread.h - found</div>
<div>
		-- Looking for pthread_create</div>
<div>
		-- Looking for pthread_create - not found</div>
<div>
		-- Looking for pthread_create in pthreads</div>
<div>
		-- Looking for pthread_create in pthreads - not found</div>
<div>
		-- Looking for pthread_create in pthread</div>
<div>
		-- Looking for pthread_create in pthread - found</div>
<div>
		-- Found Threads: TRUE &nbsp;</div>
<div>
		--&nbsp;<span style="color: rgb(0, 0, 255);">Blas libraries: /usr/lib/libblas.so</span></div>
<div>
		-- Blas linker flags:&nbsp;</div>
<div>
		-- Blas include directories:&nbsp;</div>
<div>
		-- Using BLAS include path: /usr/include</div>
<div>
		--&nbsp;<span style="color: rgb(0, 0, 255);">Using BLAS library: /usr/lib/libblas.so</span></div>
<div>
		-- Using BLAS DLLs:&nbsp;</div>
<div>
		-- Found PythonInterp: /home/codelast/.miniconda3/bin/python (found version &quot;3.6.1&quot;)&nbsp;</div>
<div>
		-- Found PythonLibs: /home/codelast/.miniconda3/lib/libpython3.6m.so (found version &quot;3.6.1&quot;)&nbsp;</div>
<div>
		-- Found SWIG: /usr/local/bin/swig (found suitable version &quot;3.0.12&quot;, minimum required is &quot;3.0.12&quot;)&nbsp;</div>
<div>
		-- Creating wrappers for python</div>
<div>
		-- Creating wrappers for javascript</div>
<div>
		-- Creating wrappers for xml</div>
<div>
		-- Using python found at: /home/codelast/.miniconda3/bin/python</div>
<div>
		-- Using python libraries found at: /home/codelast/.miniconda3/lib/libpython3.6m.so</div>
<div>
		-- Creating wrappers for python</div>
<div>
		-- Generated target compiled_vgg16ImageNet_host</div>
<div>
		-- Generated target compiled_vgg16ImageNet_pi3</div>
<div>
		-- Generated target compiled_vgg16ImageNet_pi0</div>
<div>
		-- Generated target compiled_darknetReference_host</div>
<div>
		-- Generated target compiled_darknetReference_pi3</div>
<div>
		-- Generated target compiled_darknetReference_pi0</div>
<div>
		-- Configuring done</div>
<div>
		-- Generating done</div>
<div>
		-- Build files have been written to: /home/codelast/programme/pi/ELL/build</div>
</blockquote>
<div>
	从标蓝的那两句，可见我已经成功地把atlas给除掉了。<br />
	此时，再重新make，就能成功编译ELL了！<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e8%a7%a3%e5%86%b3%e7%bc%96%e8%af%91ell%e7%9a%84%e9%94%99%e8%af%af%ef%bc%9aundefined-reference-to-cblas_xxx/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 在Ubuntu 14.04系统中为ELL安装Python 3.6——通过miniconda</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%b8%baell%e5%ae%89%e8%a3%85python-3-6-%e9%80%9a%e8%bf%87miniconda/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%b8%baell%e5%ae%89%e8%a3%85python-3-6-%e9%80%9a%e8%bf%87miniconda/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Sat, 15 Jul 2017 16:10:15 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[ELL]]></category>
		<category><![CDATA[miniconda]]></category>
		<category><![CDATA[Python 3.6]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9493</guid>

					<description><![CDATA[<p>
<a href="https://github.com/Microsoft/ELL" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>的tutorial使用的是Python 3.6，因此，为了能少走弯路，我们最好也同样使用Python 3.6。<br />
同时，文档还建议我们最好使用<a href="https://www.continuum.io/" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">anaconda</span></a>或者<a href="https://conda.io/miniconda.html" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">miniconda</span></a>。所以这里又牵扯出另一个问题：anaconda和miniconda是什么？<br />
<span id="more-9493"></span><br />
按照anaconda官方的<a href="https://www.continuum.io/what-is-anaconda" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">说法</span></a>：</p>
<blockquote>
<p>
		Anaconda is the world&#8217;s most popular and trusted data science ecosystem.</p>
</blockquote>
<p>这句话太大了，没有了解过的人看了也不知道它具体指的是什么。其实anaconda可以理解为一个Python发行版，就像Ubuntu是一个Linux发行版一样。<br />
在anaconda中，你可以用&#160;<span style="color: rgb(0, 0, 255);">conda install xxx</span>&#160;命令很方便地安装各种科学计算所需的Python module，就像Ubuntu用 apt-get install xxx 安装各种软件一样容易。<br />
这样的话，我们就无需自己去折腾安装各种Python module的依赖问题了，可以节省大量时间。<br />
而miniconda是anaconda的精简版，就像Ubuntu的某些精简版一样，里面只包含最基本的一些软件，所以，安装miniconda比anaconda占用的磁盘空间要小得多。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
我安装的是miniconda（Python 3.6，64bit版本），安装方法实在太简单，先到<a href="https://conda.io/miniconda.html" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">这里</span></a>下载安装程序，然后执行安装程序即可，在安装的过程中会要你指定安装路径，我把它安装到了当前用户的 ~/.miniconda3/&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%b8%baell%e5%ae%89%e8%a3%85python-3-6-%e9%80%9a%e8%bf%87miniconda/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
<a href="https://github.com/Microsoft/ELL" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>的tutorial使用的是Python 3.6，因此，为了能少走弯路，我们最好也同样使用Python 3.6。<br />
同时，文档还建议我们最好使用<a href="https://www.continuum.io/" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">anaconda</span></a>或者<a href="https://conda.io/miniconda.html" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">miniconda</span></a>。所以这里又牵扯出另一个问题：anaconda和miniconda是什么？<br />
<span id="more-9493"></span><br />
按照anaconda官方的<a href="https://www.continuum.io/what-is-anaconda" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">说法</span></a>：</p>
<blockquote>
<p>
		Anaconda is the world&rsquo;s most popular and trusted data science ecosystem.</p>
</blockquote>
<p>这句话太大了，没有了解过的人看了也不知道它具体指的是什么。其实anaconda可以理解为一个Python发行版，就像Ubuntu是一个Linux发行版一样。<br />
在anaconda中，你可以用&nbsp;<span style="color: rgb(0, 0, 255);">conda install xxx</span>&nbsp;命令很方便地安装各种科学计算所需的Python module，就像Ubuntu用 apt-get install xxx 安装各种软件一样容易。<br />
这样的话，我们就无需自己去折腾安装各种Python module的依赖问题了，可以节省大量时间。<br />
而miniconda是anaconda的精简版，就像Ubuntu的某些精简版一样，里面只包含最基本的一些软件，所以，安装miniconda比anaconda占用的磁盘空间要小得多。<br />
<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
我安装的是miniconda（Python 3.6，64bit版本），安装方法实在太简单，先到<a href="https://conda.io/miniconda.html" target="_blank" rel="noopener noreferrer"><span style="background-color:#ffa07a;">这里</span></a>下载安装程序，然后执行安装程序即可，在安装的过程中会要你指定安装路径，我把它安装到了当前用户的 ~/.miniconda3/ 目录下，并且在安装即将结束的时候，允许miniconda把PATH路径添加到我的 .bashrc 文件中：</p>
<blockquote><p>
	# added by Miniconda3 4.3.21 installer<br />
	export PATH=&quot;/home/codelast/.miniconda3/bin:$PATH&quot;</p></blockquote>
<div>
	此时，你要么重启Ubuntu系统，要么在Ubuntu命令行下直接&nbsp;<span style="color: rgb(0, 0, 255);">source ~/.bashrc</span>，都可以让命令行可以识别到 conda 命令&mdash;&mdash;因为 conda 这个程序就是在 ~/.miniconda3/bin/ 目录下。<br />
	至此，Python 3.6其实就已经装好了&mdash;&mdash;看看 ~/.miniconda3/bin/ 目录下是不是已经有了python3.6程序？<br />
	然后你可以用 conda install xxx 来安装其他的软件包了，conda安装的程序，是安装到了miniconda环境里，不会对覆盖系统里已有的程序，这简直太方便了。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e7%b3%bb%e7%bb%9f%e4%b8%ad%e4%b8%baell%e5%ae%89%e8%a3%85python-3-6-%e9%80%9a%e8%bf%87miniconda/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
		<item>
		<title>[原创] 在Ubuntu 14.04中安装gcc 6</title>
		<link>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e4%b8%ad%e5%ae%89%e8%a3%85gcc-6/</link>
					<comments>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e4%b8%ad%e5%ae%89%e8%a3%85gcc-6/#respond</comments>
		
		<dc:creator><![CDATA[learnhard]]></dc:creator>
		<pubDate>Fri, 14 Jul 2017 17:18:06 +0000</pubDate>
				<category><![CDATA[Linux]]></category>
		<category><![CDATA[原创]]></category>
		<category><![CDATA[ELL]]></category>
		<category><![CDATA[Ubuntu 14.04]]></category>
		<category><![CDATA[安装gcc 6.3]]></category>
		<guid isPermaLink="false">https://www.codelast.com/?p=9496</guid>

					<description><![CDATA[<p>
成功编译<a href="https://github.com/Microsoft/ELL" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>对gcc版本有要求，这而这一点在ELL的文档中并没有写。<br />
gcc版本太低了是不行的，那么什么算版本低？反正我的gcc 4.8.4是不work的&#8212;&#8212;使用低版本的gcc，你也可以照着文档完成很多步骤，但是到最后某一步，一定会遇到由于gcc版本低导致的问题，并且还没有直观的错误提示，查找问题源头可能会浪费你很多时间。<br />
<span id="more-9496"></span><br />
我在ELL的issue列表中看到有人说用gcc 6.3是OK的。但是，在Ubuntu 14.04上通过编译源码安装gcc 6并不那么容易。通过Google，我找到了如下<a href="http://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这个</span></a>很棒的答案，只需要在命令行粘贴如下命令再回车，就安装上了gcc 6，实在太爽：</p>
<pre class="bash" style="padding: 6px; border-style: solid; border-color: rgb(153, 153, 153); background: rgb(244, 244, 255); color: rgb(15, 15, 15); font-size: 15px;">
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> build-essential software-properties-common <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> add-apt-repository ppa:ubuntu-toolchain-r<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(122, 8, 116); font-weight: bold;">test</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-snapshot <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-<span style="color: rgb(0, 0, 0);">6</span> g++-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> update-alternatives <span style="color: rgb(102, 0, 51);">--install</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>gcc-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(0, 0, 0);">60</span> <span style="color: rgb(102, 0, 51);">--slave</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>g++-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-<span style="color: rgb(0, 0, 0);">4.8</span> g++-<span style="color: rgb(0, 0, 0);">4.8</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&#38;&#38;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> update-alternatives <span style="color: rgb(102, 0, 51);">--install</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>gcc-<span style="color: rgb(0, 0, 0);">4.8</span> <span style="color: rgb(0, 0, 0);">60</span> <span style="color: rgb(102, 0, 51);">--slave</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>g++-<span style="color: rgb(0, 0, 0);">4.8</span>;</pre>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a>&#8230; <a href="https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e4%b8%ad%e5%ae%89%e8%a3%85gcc-6/" class="read-more">Read More </a></p>]]></description>
										<content:encoded><![CDATA[<p>
成功编译<a href="https://github.com/Microsoft/ELL" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">ELL</span></a>对gcc版本有要求，这而这一点在ELL的文档中并没有写。<br />
gcc版本太低了是不行的，那么什么算版本低？反正我的gcc 4.8.4是不work的&mdash;&mdash;使用低版本的gcc，你也可以照着文档完成很多步骤，但是到最后某一步，一定会遇到由于gcc版本低导致的问题，并且还没有直观的错误提示，查找问题源头可能会浪费你很多时间。<br />
<span id="more-9496"></span><br />
我在ELL的issue列表中看到有人说用gcc 6.3是OK的。但是，在Ubuntu 14.04上通过编译源码安装gcc 6并不那么容易。通过Google，我找到了如下<a href="http://gist.github.com/application2000/73fd6f4bf1be6600a2cf9f56315a2d91" target="_blank" rel="noopener noreferrer"><span style="background-color: rgb(255, 160, 122);">这个</span></a>很棒的答案，只需要在命令行粘贴如下命令再回车，就安装上了gcc 6，实在太爽：</p>
<pre class="bash" style="padding: 6px; border-style: solid; border-color: rgb(153, 153, 153); background: rgb(244, 244, 255); color: rgb(15, 15, 15); font-size: 15px;">
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> build-essential software-properties-common <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> add-apt-repository ppa:ubuntu-toolchain-r<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(122, 8, 116); font-weight: bold;">test</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-snapshot <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get update</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-<span style="color: rgb(0, 0, 0);">6</span> g++-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> update-alternatives <span style="color: rgb(102, 0, 51);">--install</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>gcc-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(0, 0, 0);">60</span> <span style="color: rgb(102, 0, 51);">--slave</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>g++-<span style="color: rgb(0, 0, 0);">6</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">apt-get install</span> gcc-<span style="color: rgb(0, 0, 0);">4.8</span> g++-<span style="color: rgb(0, 0, 0);">4.8</span> <span style="color: rgb(102, 0, 51);">-y</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">&amp;&amp;</span> \
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> update-alternatives <span style="color: rgb(102, 0, 51);">--install</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>gcc-<span style="color: rgb(0, 0, 0);">4.8</span> <span style="color: rgb(0, 0, 0);">60</span> <span style="color: rgb(102, 0, 51);">--slave</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span><span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">g++</span> <span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>usr<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>bin<span style="color: rgb(0, 0, 0); font-weight: bold;">/</span>g++-<span style="color: rgb(0, 0, 0);">4.8</span>;</pre>
<p><span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" target="_blank" rel="noopener noreferrer"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
安装完成后，使用如下命令选择gcc版本：</p>
<pre class="bash" style="padding: 6px; border-style: solid; border-color: rgb(153, 153, 153); background: rgb(244, 244, 255); color: rgb(15, 15, 15); font-size: 15px;">
<span style="color: rgb(194, 12, 185); font-weight: bold;">sudo</span> update-alternatives <span style="color: rgb(102, 0, 51);">--config</span> <span style="color: rgb(194, 12, 185); font-weight: bold;">gcc</span></pre>
<p>会打印出如下提示：</p>
<blockquote>
<div>
		There are 2 choices for the alternative gcc (providing /usr/bin/gcc).</div>
<div>
		&nbsp;</div>
<div>
		&nbsp; Selection &nbsp; &nbsp;Path &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Priority &nbsp; Status</div>
<div>
		------------------------------------------------------------</div>
<div>
		* 0 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/usr/bin/gcc-6 &nbsp; &nbsp; 60 &nbsp; &nbsp; &nbsp; &nbsp;auto mode</div>
<div>
		&nbsp; 1 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/usr/bin/gcc-4.8 &nbsp; 60 &nbsp; &nbsp; &nbsp; &nbsp;manual mode</div>
<div>
		&nbsp; 2 &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;/usr/bin/gcc-6 &nbsp; &nbsp; 60 &nbsp; &nbsp; &nbsp; &nbsp;manual mode</div>
</blockquote>
<p>直接回车就是使用默认的gcc 6.3。<br />
此时，再用 gcc -v 命令检查一下版本，我的输出如下：</p>
<blockquote>
<div>
		Using built-in specs.</div>
<div>
		COLLECT_GCC=gcc</div>
<div>
		COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper</div>
<div>
		Target: x86_64-linux-gnu</div>
<div>
		Configured with: ...(内容很长，省略)</div>
<div>
		Thread model: posix</div>
<div>
		gcc version 6.3.0 20170519 (Ubuntu/Linaro 6.3.0-18ubuntu2~14.04)</div>
</blockquote>
<div>
	这就OK了。<br />
	<span style="color: rgb(255, 255, 255);">文章来源：</span><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><span style="color: rgb(255, 255, 255);">https://www.codelast.com/</span></a><br />
	<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;版权声明&nbsp;<span style="color: rgb(255, 0, 0);">➤➤</span>&nbsp;<br />
	转载需注明出处：<u><a href="https://www.codelast.com/" rel="noopener noreferrer" target="_blank"><em><span style="color: rgb(0, 0, 255);"><strong style="font-size: 16px;"><span style="font-family: arial, helvetica, sans-serif;">codelast.com</span></strong></span></em></a></u>&nbsp;<br />
	感谢关注我的微信公众号（微信扫一扫）：</p>
<p style="border: 0px; font-size: 13px; margin: 0px 0px 9px; outline: 0px; padding: 0px; color: rgb(77, 77, 77);">
		<img decoding="async" alt="wechat qrcode of codelast" src="https://www.codelast.com/codelast_wechat_qr_code.jpg" style="width: 200px; height: 200px;" /></p>
</div>
]]></content:encoded>
					
					<wfw:commentRss>https://www.codelast.com/%e5%8e%9f%e5%88%9b-%e5%9c%a8ubuntu-14-04%e4%b8%ad%e5%ae%89%e8%a3%85gcc-6/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
			</item>
	</channel>
</rss>
