解决Ubuntu18.04/16.04 Cuda10.0.130 cudnn7.3.1 tensorflow1.12 libcusolver.so.9.0: cannot open问题

@[TOC](解决Ubuntu18.04/16.04 Cuda10.0.130 cudnn7.3.1 tensorflow1.12 libcusolver.so.9.0: cannot open问题)

# libcusolver.so.9.0: cannot open问题

源码编译太烦,又容易手贱更新系统软件(软件更新器)然后nvidia-smi就fail to load :driver/library dont match。好吧,我认。重装驱动,ctrl+Alt+F3 load driver,fail,又timeshift了好几回满血复活,他嘛ubuntu就是为了折腾而生。
![nvidia-smi](https://img-blog.csdnimg.cn/20190103222148251.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3UwMTE0ODYzMDc=,size_16,color_FFFFFF,t_70)
## stackover&github

可能是我一直找错了,找到的都是cuda9.0不行的问题,正确的搜法是

> cuda10 ubuntu tensorflow1.12

https://github.com/tensorflow/tensorflow/issues/22706
没其他坑了,直接给我的系统的解决方案
https://drive.google.com/file/d/1QV7fBi5ZpTm02N1_QbyEhT6v80B6Zffg/view?usp=sharing

```
pip install /path-to-wheel/
```

【第一次使用CSDN】wordpress升级5.0.1后updating fail & publishing fail的解决方法

使用wordpress的原因

闲着无聊

闲暇无事,想学html+js+css,又想练练手就在某天晚上搞了个腾讯云,本来想在本地群辉搭一个wordpress服务器然后内网穿透到云上,但,学校网墙太厚,ngnix老容易断。那就直接到云上呗。 本来腾讯云直接就有wordpress的镜像,本着不折腾不是人的信念打开【腾讯云的1001种玩法】如何使用腾讯云做博客,好吧,搞定了。突然来了个升级按钮,from 4.7.8-5.0.1 一看好美的UI就升了。

wordpress遇到过的bug

1.腾讯云centOS /data/wwwroot/default权限不够问题 2.客户端XML-RPC上传失败问题 3.“偶,糟糕网页不见了” UTF8编码设置问题 以上还好,百度有中文版解答。附上centos Apache、php、mysql默认安装路径 可是下一个 升级5.0.1上传时和update时,updating fail & publishing fail,WTF?黑人问号

可能的 case

How to fix WordPress 5 Publishing failed or Updating failed issue GitHub上大家基本都不是这个问题,大概只有真的从头来一遍才是吧。

My case

找了挺久的Apache&php&Mysql的错误 发现主要错误集中在.htaccess上,结果他说是Apache的问题,那就没问题,找到位置开工,我的文件位置在/usr/local/apache/conf/httpd.conf 从这里找到的。但你们debug的时候别忘记把固定链接换成自定义结构。
nano /usr/local/apache/conf/httpd.conf
改这两个地方
<Directory "/data/wwwroot/default">

    Options Indexes FollowSymLinks
    AllowOverride All
    Require all granted
    
</Directory>
<Files ".ht*">

    Require all granted
    
</Files>
然后
service apache restart
service apache2 restart
service httpd restart
搞定

现行最好用的全自动读入

getchar+fread+位运算存入

char ss[1<<17],*A=ss,*B=ss;
inline char gc(){if(A==B){B=(A=ss)+fread(ss,1,1<<17,stdin);if(A==B)return EOF;}return *A++;}
template<class T>inline void read(T&x){
    char c;re y=1;while(c=gc(),c<48||57<c)if(c=='-')y=-1;x=c^48;
    while(c=gc(),47<c&&c<58)x=(x<<1)+(x<<3)+(c^48);x*=y;
}

用法 in BNF

<any type> read(a);

Use python to carry on hw4_3 C++ kernel

做完那个脑残cpp作业以后就对卷积有了很好的印象,,虽然我是一个连线代都没学到的小辣鸡。

下面的程序真的是配置100分钟,运行0.01s 科科,大致就是用库3D卷积。kernel在库里面。

import tensorflow as tf
from tensorflow.python.keras import backend as K
import dropblock
import torch

class DropBlock(tf.keras.layers.Layer):
def __init__(self, keep_prob, block_size, **kwargs):
super(DropBlock, self).__init__(**kwargs)
self.keep_prob = float(keep_prob) if isinstance(keep_prob, int) else keep_prob
self.block_size = int(block_size)

def compute_output_shape(self, input_shape):
return input_shape

def build(self, input_shape):
_, self.h, self.w, self.channel = input_shape.as_list()
# pad the mask
bottom = right = (self.block_size - 1) // 2
top = left = (self.block_size - 1) - bottom
self.padding = [[0, 0], [top, bottom], [left, right], [0, 0]]
self.set_keep_prob()
super(DropBlock, self).build(input_shape)

def call(self, inputs, training=None, scale=True, **kwargs):
def drop():
mask = self._create_mask(tf.shape(inputs))
output = inputs * mask
output = tf.cond(tf.constant(scale, dtype=tf.bool) if isinstance(scale, bool) else scale,
true_fn=lambda: output * tf.to_float(tf.size(mask)) / tf.reduce_sum(mask),
false_fn=lambda: output)
return output

if training is None:
training = K.learning_phase()
output = tf.cond(tf.logical_or(tf.logical_not(training), tf.equal(self.keep_prob, 1.0)),
true_fn=lambda: inputs,
false_fn=drop)
return output

def set_keep_prob(self, keep_prob=None):
"""This method only supports Eager Execution"""
if keep_prob is not None:
self.keep_prob = keep_prob
w, h = tf.to_float(self.w), tf.to_float(self.h)
self.gamma = (1. - self.keep_prob) * (w * h) / (self.block_size ** 2) / \
((w - self.block_size + 1) * (h - self.block_size + 1))

def _create_mask(self, input_shape):
sampling_mask_shape = tf.stack([input_shape[0],
self.h - self.block_size + 1,
self.w - self.block_size + 1,
self.channel])
mask = DropBlock._bernoulli(sampling_mask_shape, self.gamma)
mask = tf.pad(mask, self.padding)
mask = tf.nn.max_pool(mask, [1, self.block_size, self.block_size, 1], [1, 1, 1, 1], 'SAME')
mask = 1 - mask
return mask

@staticmethod
def _bernoulli(shape, mean):
return tf.nn.relu(tf.sign(mean - tf.random_uniform(shape, minval=0, maxval=1, dtype=tf.float32)))

tf.enable_eager_execution()

# only support `channels_last` data format
a = tf.ones([2, 10, 10, 3])

drop_block = DropBlock(keep_prob=0.8, block_size=3)
b = drop_block(a, training=True)

print(a[0, :, :, 0])
print(b[0, :, :, 0])

配置tensorflow anaconda & vscode

直接conda install xxx就好,没有必要每一个都pip 尤其是这种conda环境,又要cuda环境gpu加速的。pytorch 注意要 ==0.4.1!

最后就是环境了(大概只有win和linux有这个需求)

手动滑稽hi
import dropblock

rather than

from dropblock import dropblock

输出结果

2018-12-16 03:07:07.196585: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
tf.Tensor(
[[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]
[1. 1. 1. 1. 1. 1. 1. 1. 1. 1.]], shape=(10, 10), dtype=float32)
tf.Tensor(
[[1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 1.2631578
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 0. 0. 0. 1.2631578
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 0. 0. 0. 1.2631578
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 0. 0. 0. 0.
0. 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 0. 0.
0. 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 0. 0.
0. 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 0. 0. 0.
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 0. 0. 0.
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 0. 0. 0.
1.2631578 1.2631578 1.2631578]
[1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 1.2631578 1.2631578
1.2631578 1.2631578 1.2631578]], shape=(10, 10), dtype=float32)

CF1189B Number Circle

水题

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<deque>

using namespace std;
const int inf = 1e5 + 5;
int n, s[inf],cnt;
deque<int> q;
int main()
{
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)scanf("%d", &s[i]);
	sort(s, s + n + 1);
    for(int i=n;i>=1;i--)
    {
        if(cnt)q.push_front(s[i]),cnt^=1;
        else q.push_back(s[i]),cnt^=1;
    }
    cnt=0;
    deque<int>::iterator it;
    for(it=q.begin();it!=q.end();it++)
    s[++cnt]= *it ;
    for(int i=2;i<=n-1;i++)
    if(s[i-1]+s[i+1]<=s[i]){cout<<"NO";return 0;}
    if(s[n-1]+s[1]<=s[n]){cout<<"NO";return 0;}
    cout<<"YES"<<endl;
	for (int i = 1; i <= n; i++)cout << s[i] << " ";
	return 0;
}